|
5 | 5 | description: 'Target architecture (x64 or x86)' |
6 | 6 | required: true |
7 | 7 | default: 'x64' |
| 8 | + cache_key: |
| 9 | + description: 'a workflow & job qualified unique key to distinguish a cache. used as a suffix for subcaches.' |
| 10 | + required: true |
8 | 11 | outputs: |
9 | 12 | vcvarsall_path: |
10 | 13 | description: "Path to vcvarsall.bat" |
|
78 | 81 |
|
79 | 82 | REM Call the Python script to update the GitHub Actions environment |
80 | 83 | python ${{ github.action_path }}\update_environment.py |
| 84 | +
|
| 85 | + - name: Set cache dir env vars |
| 86 | + env: |
| 87 | + github_runner_temp: ${{ runner.temp }} |
| 88 | + shell: pwsh |
| 89 | + run: | |
| 90 | + echo "CCACHE_DIR=${env:github_runner_temp}/.ccache" >> "${env:GITHUB_ENV}" |
| 91 | + echo "VCPKG_DEFAULT_BINARY_CACHE=${env:github_runner_temp}/.vcpkg-cache" >> "${env:GITHUB_ENV}" |
| 92 | +
|
| 93 | + # vcpkg will error/exit if `VCPKG_DEFAULT_BINARY_CACHE` does not exist as a directory. |
| 94 | + # c.f. ccache happily creates the cache dir if it does not exist. |
| 95 | + # Don't create ccache's dir so that `action/cache` skips if ccache isn't populated. |
| 96 | + New-Item -ItemType Directory -Path "${env:github_runner_temp}/.vcpkg-cache" -Force |
| 97 | +
|
| 98 | + # HACK: `actions/cache` will somehow pick up `tar` from the git installation. This bin dir is not on the PATH. |
| 99 | + # `tar` tries to find `gzip` (which is right next to it), and fails b/c the git bin dir isn't on the PATH. |
| 100 | + # This breaks attempts to upload a new cache. |
| 101 | + # Add git's bin dir to the PATH so that `actions/cache`'s invoke of `tar` can find `gzip`. |
| 102 | + echo "PATH=${env:PATH};C:\\Program Files\\Git\\usr\\bin" >> "${env:GITHUB_ENV}" |
| 103 | +
|
| 104 | + # n.b. Caller is responsible for building w/ ccache enabled via `--use_cache` |
| 105 | + # We could set the env var `ORT_BUILD_WITH_CACHE` to indirectly enable it, but this hack seems deprecated. |
| 106 | + # Ideally ccache should be auto-enabled by the build system if ccache/sccache is detected on the PATH. |
| 107 | + - name: Setup CCache |
| 108 | + uses: actions/cache@v4 |
| 109 | + with: |
| 110 | + # Fully qualify by `cache_key`. `actions/cache` does not isolate by workflow, unlike ADO cache actions. |
| 111 | + key: ccache | ${{ inputs.cache_key }} |
| 112 | + path: ${{ runner.temp }}/.ccache # ensure this is coordinated/matches w/ env-vars step above |
| 113 | + |
| 114 | + - name: Setup VCPKG Cache |
| 115 | + uses: actions/cache@v4 |
| 116 | + with: |
| 117 | + key: vcpkg-cache | ${{ inputs.cache_key }} |
| 118 | + path: ${{ runner.temp }}/.vcpkg-cache |
0 commit comments