From e29e077a030d70b5f1dfa89a83572a738d241048 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Thu, 12 Jan 2023 13:25:37 +0100 Subject: [PATCH] Ruby/QL4QL: include OS version in cache keys --- .github/actions/os-version/action.yml | 32 +++++++++++++++++++ .github/workflows/ql-for-ql-build.yml | 10 +++--- .../workflows/ql-for-ql-dataset_measure.yml | 4 ++- .github/workflows/ql-for-ql-tests.yml | 4 ++- .github/workflows/ruby-build.yml | 6 ++-- ruby/actions/create-extractor-pack/action.yml | 6 ++-- 6 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 .github/actions/os-version/action.yml diff --git a/.github/actions/os-version/action.yml b/.github/actions/os-version/action.yml new file mode 100644 index 00000000000..31a33b7a937 --- /dev/null +++ b/.github/actions/os-version/action.yml @@ -0,0 +1,32 @@ +name: OS Version +description: Get OS version. + +outputs: + version: + description: "OS version" + value: ${{ steps.version.outputs.version }} + +runs: + using: composite + steps: + - if: runner.os == 'Linux' + shell: bash + run: | + . /etc/os-release + echo "VERSION=${NAME} ${VERSION}" >> $GITHUB_ENV + - if: runner.os == 'Windows' + shell: powershell + run: | + $objects = systeminfo.exe /FO CSV | ConvertFrom-Csv + "VERSION=$($objects.'OS Name') $($objects.'OS Version')" >> $env:GITHUB_ENV + - if: runner.os == 'macOS' + shell: bash + run: | + echo "VERSION=$(sw_vers -productName) $(sw_vers -productVersion)" >> $GITHUB_ENV + - name: Emit OS version + id: version + shell: bash + run: | + echo "$VERSION" + echo "version=${VERSION}" >> $GITHUB_OUTPUT + diff --git a/.github/workflows/ql-for-ql-build.yml b/.github/workflows/ql-for-ql-build.yml index 29b8bc16300..553fd7bb51c 100644 --- a/.github/workflows/ql-for-ql-build.yml +++ b/.github/workflows/ql-for-ql-build.yml @@ -38,12 +38,14 @@ jobs: shell: bash env: CODEQL: ${{ steps.find-codeql.outputs.codeql-path }} + - uses: ./.github/actions/os-version + id: os_version - name: Cache entire pack id: cache-pack uses: actions/cache@v3 with: path: ${{ runner.temp }}/pack - key: ${{ runner.os }}-pack-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}-${{ hashFiles('ql/**/*.ql*') }}-${{ hashFiles('ql/**/qlpack.yml') }}-${{ hashFiles('ql/ql/src/ql.dbscheme*') }}-${{ steps.get-codeql-version.outputs.version }}--${{ hashFiles('.github/workflows/ql-for-ql-build.yml') }} + key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-pack-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}-${{ hashFiles('ql/**/*.ql*') }}-${{ hashFiles('ql/**/qlpack.yml') }}-${{ hashFiles('ql/ql/src/ql.dbscheme*') }}-${{ steps.get-codeql-version.outputs.version }}--${{ hashFiles('.github/workflows/ql-for-ql-build.yml') }} - name: Cache queries if: steps.cache-pack.outputs.cache-hit != 'true' id: cache-queries @@ -77,7 +79,7 @@ jobs: ql/target/release/ql-autobuilder.exe ql/target/release/ql-extractor ql/target/release/ql-extractor.exe - key: ${{ runner.os }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }} + key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }} - name: Cache cargo if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true' uses: actions/cache@v3 @@ -86,7 +88,7 @@ jobs: ~/.cargo/registry ~/.cargo/git ql/target - key: ${{ runner.os }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }} + key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }} - name: Check formatting if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true' run: cd ql; cargo fmt --all -- --check @@ -172,4 +174,4 @@ jobs: with: name: ql-for-ql-langs path: split-sarif - retention-days: 1 \ No newline at end of file + retention-days: 1 diff --git a/.github/workflows/ql-for-ql-dataset_measure.yml b/.github/workflows/ql-for-ql-dataset_measure.yml index 41f95a686ba..90614711d0c 100644 --- a/.github/workflows/ql-for-ql-dataset_measure.yml +++ b/.github/workflows/ql-for-ql-dataset_measure.yml @@ -28,13 +28,15 @@ jobs: uses: github/codeql-action/init@77a8d2d10c0b403a8b4aadbd223dc489ecd22683 with: languages: javascript # does not matter + - uses: ./.github/actions/os-version + id: os_version - uses: actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git ql/target - key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }} + key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }} - name: Build Extractor run: cd ql; env "PATH=$PATH:`dirname ${CODEQL}`" ./scripts/create-extractor-pack.sh env: diff --git a/.github/workflows/ql-for-ql-tests.yml b/.github/workflows/ql-for-ql-tests.yml index ce7963e8f79..fd8001de8c7 100644 --- a/.github/workflows/ql-for-ql-tests.yml +++ b/.github/workflows/ql-for-ql-tests.yml @@ -25,13 +25,15 @@ jobs: uses: github/codeql-action/init@77a8d2d10c0b403a8b4aadbd223dc489ecd22683 with: languages: javascript # does not matter + - uses: ./.github/actions/os-version + id: os_version - uses: actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git ql/target - key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }} + key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }} - name: Build extractor run: | cd ql; diff --git a/.github/workflows/ruby-build.yml b/.github/workflows/ruby-build.yml index e272f2ba319..e371ffcae27 100644 --- a/.github/workflows/ruby-build.yml +++ b/.github/workflows/ruby-build.yml @@ -48,6 +48,8 @@ jobs: run: | brew install gnu-tar echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH + - uses: ./.github/actions/os-version + id: os_version - name: Cache entire extractor uses: actions/cache@v3 id: cache-extractor @@ -58,7 +60,7 @@ jobs: ruby/target/release/ruby-extractor ruby/target/release/ruby-extractor.exe ruby/ql/lib/codeql/ruby/ast/internal/TreeSitter.qll - key: ${{ runner.os }}-ruby-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}--${{ hashFiles('ruby/**/*.rs') }} + key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}--${{ hashFiles('ruby/**/*.rs') }} - uses: actions/cache@v3 if: steps.cache-extractor.outputs.cache-hit != 'true' with: @@ -66,7 +68,7 @@ jobs: ~/.cargo/registry ~/.cargo/git ruby/target - key: ${{ runner.os }}-ruby-rust-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }} + key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-rust-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }} - name: Check formatting if: steps.cache-extractor.outputs.cache-hit != 'true' run: cargo fmt --all -- --check diff --git a/ruby/actions/create-extractor-pack/action.yml b/ruby/actions/create-extractor-pack/action.yml index 667158c264c..7062dd0cfcd 100644 --- a/ruby/actions/create-extractor-pack/action.yml +++ b/ruby/actions/create-extractor-pack/action.yml @@ -3,12 +3,14 @@ description: Builds the Ruby CodeQL pack runs: using: composite steps: + - uses: ./.github/actions/os-version + id: os_version - name: Cache entire extractor id: cache-extractor uses: actions/cache@v3 with: path: ruby/extractor-pack - key: ${{ runner.os }}-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}-${{ hashFiles('ruby/**/*.rs') }}-${{ hashFiles('ruby/codeql-extractor.yml', 'ruby/downgrades', 'ruby/tools', 'ruby/ql/lib/ruby.dbscheme', 'ruby/ql/lib/ruby.dbscheme.stats') }} + key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}-${{ hashFiles('ruby/**/*.rs') }}-${{ hashFiles('ruby/codeql-extractor.yml', 'ruby/downgrades', 'ruby/tools', 'ruby/ql/lib/ruby.dbscheme', 'ruby/ql/lib/ruby.dbscheme.stats') }} - name: Cache cargo uses: actions/cache@v3 if: steps.cache-extractor.outputs.cache-hit != 'true' @@ -17,7 +19,7 @@ runs: ~/.cargo/registry ~/.cargo/git ruby/target - key: ${{ runner.os }}-ruby-qltest-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }} + key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-qltest-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }} - name: Build Extractor if: steps.cache-extractor.outputs.cache-hit != 'true' shell: bash