Skip to content

Commit af8cb65

Browse files
authored
Merge pull request github#11877 from aibaars/ql-ql-cross
QL/Ruby: include OS version in cache keys for Rust binaries
2 parents 8aa2c23 + e29e077 commit af8cb65

File tree

6 files changed

+52
-10
lines changed

6 files changed

+52
-10
lines changed

.github/actions/os-version/action.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: OS Version
2+
description: Get OS version.
3+
4+
outputs:
5+
version:
6+
description: "OS version"
7+
value: ${{ steps.version.outputs.version }}
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- if: runner.os == 'Linux'
13+
shell: bash
14+
run: |
15+
. /etc/os-release
16+
echo "VERSION=${NAME} ${VERSION}" >> $GITHUB_ENV
17+
- if: runner.os == 'Windows'
18+
shell: powershell
19+
run: |
20+
$objects = systeminfo.exe /FO CSV | ConvertFrom-Csv
21+
"VERSION=$($objects.'OS Name') $($objects.'OS Version')" >> $env:GITHUB_ENV
22+
- if: runner.os == 'macOS'
23+
shell: bash
24+
run: |
25+
echo "VERSION=$(sw_vers -productName) $(sw_vers -productVersion)" >> $GITHUB_ENV
26+
- name: Emit OS version
27+
id: version
28+
shell: bash
29+
run: |
30+
echo "$VERSION"
31+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
32+

.github/workflows/ql-for-ql-build.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ jobs:
3838
shell: bash
3939
env:
4040
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
41+
- uses: ./.github/actions/os-version
42+
id: os_version
4143
- name: Cache entire pack
4244
id: cache-pack
4345
uses: actions/cache@v3
4446
with:
4547
path: ${{ runner.temp }}/pack
46-
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') }}
48+
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') }}
4749
- name: Cache queries
4850
if: steps.cache-pack.outputs.cache-hit != 'true'
4951
id: cache-queries
@@ -77,7 +79,7 @@ jobs:
7779
ql/target/release/ql-autobuilder.exe
7880
ql/target/release/ql-extractor
7981
ql/target/release/ql-extractor.exe
80-
key: ${{ runner.os }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
82+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
8183
- name: Cache cargo
8284
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
8385
uses: actions/cache@v3
@@ -86,7 +88,7 @@ jobs:
8688
~/.cargo/registry
8789
~/.cargo/git
8890
ql/target
89-
key: ${{ runner.os }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
91+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
9092
- name: Check formatting
9193
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
9294
run: cd ql; cargo fmt --all -- --check
@@ -172,4 +174,4 @@ jobs:
172174
with:
173175
name: ql-for-ql-langs
174176
path: split-sarif
175-
retention-days: 1
177+
retention-days: 1

.github/workflows/ql-for-ql-dataset_measure.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ jobs:
2828
uses: github/codeql-action/init@45955cb1830b640e2c1603ad72ad542a49d47b96
2929
with:
3030
languages: javascript # does not matter
31+
- uses: ./.github/actions/os-version
32+
id: os_version
3133
- uses: actions/cache@v3
3234
with:
3335
path: |
3436
~/.cargo/registry
3537
~/.cargo/git
3638
ql/target
37-
key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
39+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
3840
- name: Build Extractor
3941
run: cd ql; env "PATH=$PATH:`dirname ${CODEQL}`" ./scripts/create-extractor-pack.sh
4042
env:

.github/workflows/ql-for-ql-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ jobs:
2525
uses: github/codeql-action/init@45955cb1830b640e2c1603ad72ad542a49d47b96
2626
with:
2727
languages: javascript # does not matter
28+
- uses: ./.github/actions/os-version
29+
id: os_version
2830
- uses: actions/cache@v3
2931
with:
3032
path: |
3133
~/.cargo/registry
3234
~/.cargo/git
3335
ql/target
34-
key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
36+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
3537
- name: Build extractor
3638
run: |
3739
cd ql;

.github/workflows/ruby-build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ jobs:
4848
run: |
4949
brew install gnu-tar
5050
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
51+
- uses: ./.github/actions/os-version
52+
id: os_version
5153
- name: Cache entire extractor
5254
uses: actions/cache@v3
5355
id: cache-extractor
@@ -58,15 +60,15 @@ jobs:
5860
ruby/target/release/ruby-extractor
5961
ruby/target/release/ruby-extractor.exe
6062
ruby/ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
61-
key: ${{ runner.os }}-ruby-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}--${{ hashFiles('ruby/**/*.rs') }}
63+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}--${{ hashFiles('ruby/**/*.rs') }}
6264
- uses: actions/cache@v3
6365
if: steps.cache-extractor.outputs.cache-hit != 'true'
6466
with:
6567
path: |
6668
~/.cargo/registry
6769
~/.cargo/git
6870
ruby/target
69-
key: ${{ runner.os }}-ruby-rust-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}
71+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-rust-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}
7072
- name: Check formatting
7173
if: steps.cache-extractor.outputs.cache-hit != 'true'
7274
run: cargo fmt --all -- --check

ruby/actions/create-extractor-pack/action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ description: Builds the Ruby CodeQL pack
33
runs:
44
using: composite
55
steps:
6+
- uses: ./.github/actions/os-version
7+
id: os_version
68
- name: Cache entire extractor
79
id: cache-extractor
810
uses: actions/cache@v3
911
with:
1012
path: ruby/extractor-pack
11-
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') }}
13+
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') }}
1214
- name: Cache cargo
1315
uses: actions/cache@v3
1416
if: steps.cache-extractor.outputs.cache-hit != 'true'
@@ -17,7 +19,7 @@ runs:
1719
~/.cargo/registry
1820
~/.cargo/git
1921
ruby/target
20-
key: ${{ runner.os }}-ruby-qltest-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}
22+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-qltest-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}
2123
- name: Build Extractor
2224
if: steps.cache-extractor.outputs.cache-hit != 'true'
2325
shell: bash

0 commit comments

Comments
 (0)