Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: cache ninja build #6920

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
if: steps.build-cache.outputs.cache-hit != 'true'
run: cargo build --manifest-path rewatch/Cargo.toml --target ${{matrix.rust-target}} --release

- name: Copy exe to platform bin dirs
- name: Copy rewatch exe to platform bin dir
run: |
cp rewatch/target/${{matrix.rust-target}}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }} rewatch
node ./scripts/copyExes.js -rewatch
Expand Down Expand Up @@ -121,8 +121,10 @@ jobs:
- name: Get artifact dir name
run: node .github/workflows/get_artifact_dir_name.js

- name: Copy exes to platform bin dirs
run: node ./scripts/copyExes.js -compiler
- name: Copy exes to platform bin dir
run: |
node ./scripts/copyExes.js -compiler
node ./scripts/copyExes.js -ninja

- name: "Upload artifacts: binaries"
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -164,6 +166,11 @@ jobs:
with:
fetch-depth: 2 # to be able to check for changes in subfolder jscomp/syntax later

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Get artifact dir name
run: node .github/workflows/get_artifact_dir_name.js

Expand All @@ -175,11 +182,6 @@ jobs:
packages: bubblewrap darcs g++-multilib gcc-multilib mercurial musl-tools rsync
version: v1

- name: Setup Python for ninja build
uses: actions/setup-python@v5
with:
python-version: '3.10'

# matrix.ocaml_compiler may contain commas
- name: Get OPAM cache key
shell: bash
Expand Down Expand Up @@ -284,32 +286,44 @@ jobs:
if: runner.os == 'Linux'
run: opam exec -- dune build --display quiet --profile static

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install npm packages
run: npm ci --ignore-scripts

- name: Copy compiler exes to platform bin dir
run: node ./scripts/copyExes.js -compiler

- name: Restore ninja build cache
id: ninja-build-cache
uses: actions/cache@v4
with:
path: ${{ env.artifact_dir_name }}/ninja.exe
key: ninja-build-v1-${{ matrix.os }}-${{ hashFiles('ninja/src/**') }}

- name: Setup Python for ninja build
if: steps.ninja-build-cache.outputs.cache-hit != 'true'
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Setup MSVC for ninja build (Windows)
if: runner.os == 'Windows'
if: steps.ninja-build-cache.outputs.cache-hit != 'true' && runner.os == 'Windows'
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64

- name: Build ninja
if: runner.os != 'Linux'
if: steps.ninja-build-cache.outputs.cache-hit != 'true' && runner.os != 'Linux'
run: node scripts/buildNinjaBinary.js

- name: Build ninja (Linux static)
if: runner.os == 'Linux'
if: steps.ninja-build-cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
env:
LDFLAGS: -static
run: node scripts/buildNinjaBinary.js

- name: Copy exes to platform bin dirs
run: node ./scripts/copyExes.js -compiler
- name: Copy ninja exe to platform bin dir
if: steps.ninja-build-cache.outputs.cache-hit != 'true'
run: node ./scripts/copyExes.js -ninja

- name: "Check if syntax subfolder has changed"
id: syntax-diff
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ rewatch:

ninja/ninja:
./scripts/buildNinjaBinary.js
./scripts/copyExes.js -ninja

ninja: ninja/ninja

Expand Down
3 changes: 3 additions & 0 deletions scripts/copyExes.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ if (process.argv.includes("-all") || process.argv.includes("-compiler")) {
copyExe(duneBinDir, "rescript");
copyExe(duneBinDir, "bsc");
copyExe(duneBinDir, "bsb_helper");
}

if (process.argv.includes("-all") || process.argv.includes("-ninja")) {
copyExe(ninjaDir, "ninja");
}

Expand Down