Skip to content

Commit

Permalink
ci: cache everything in workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
shiqimei committed Jun 14, 2023
1 parent 901189f commit 3b682d1
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 82 deletions.
88 changes: 47 additions & 41 deletions .github/workflows/cmake-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,57 @@ name: Build Debug target

on:
push:
branches: ["main"]
branches: [ "main" ]
pull_request:
branches: ["main"]
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- name: Install cbindgen
run: cargo install --force cbindgen

- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/bin
~/.ninja
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install Ninja
run: |
if [ ! -d "$HOME/.ninja" ]; then
mkdir $HOME/.ninja
curl -L https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip -o $HOME/.ninja/ninja.zip
unzip $HOME/.ninja/ninja.zip -d $HOME/.ninja
echo "$HOME/.ninja" >> $GITHUB_PATH
fi
- name: Configure CMake
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Debug

- name: Build target
run: cmake --build ${{github.workspace}}/build --target qjs run-test262 -j 8

- name: Test
run: ./bin/qjs -e 'console.log("Hello, World!")'
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo
~/.ninja
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Setup Rust
run: |
if ! command -v rustup &> /dev/null
then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. $HOME/.cargo/env
rustup default nightly
fi
- name: Install cbindgen
run: |
if ! command -v cbindgen &> /dev/null
then
cargo install --force cbindgen
fi
- name: Install Ninja
run: |
if [ ! -d "$HOME/.ninja" ]; then
mkdir $HOME/.ninja
curl -L https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip -o $HOME/.ninja/ninja.zip
unzip $HOME/.ninja/ninja.zip -d $HOME/.ninja
echo "$HOME/.ninja" >> $GITHUB_PATH
fi
- name: Configure CMake
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Debug

- name: Build target
run: cmake --build ${{github.workspace}}/build --target qjs run-test262 -j 8

- name: Test
run: ./bin/qjs -e 'console.log("Hello, World!")'
88 changes: 47 additions & 41 deletions .github/workflows/cmake-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,57 @@ name: Build Release target

on:
push:
branches: ["main"]
branches: [ "main" ]
pull_request:
branches: ["main"]
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- name: Install cbindgen
run: cargo install --force cbindgen

- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/bin
~/.ninja
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install Ninja
run: |
if [ ! -d "$HOME/.ninja" ]; then
mkdir $HOME/.ninja
curl -L https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip -o $HOME/.ninja/ninja.zip
unzip $HOME/.ninja/ninja.zip -d $HOME/.ninja
echo "$HOME/.ninja" >> $GITHUB_PATH
fi
- name: Configure CMake
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release

- name: Build target
run: cmake --build ${{github.workspace}}/build --target qjs run-test262 -j 8

- name: Test
run: ./bin/qjs -e 'console.log("Hello, World!")'
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo
~/.ninja
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Setup Rust
run: |
if ! command -v rustup &> /dev/null
then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. $HOME/.cargo/env
rustup default nightly
fi
- name: Install cbindgen
run: |
if ! command -v cbindgen &> /dev/null
then
cargo install --force cbindgen
fi
- name: Install Ninja
run: |
if [ ! -d "$HOME/.ninja" ]; then
mkdir $HOME/.ninja
curl -L https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip -o $HOME/.ninja/ninja.zip
unzip $HOME/.ninja/ninja.zip -d $HOME/.ninja
echo "$HOME/.ninja" >> $GITHUB_PATH
fi
- name: Configure CMake
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release

- name: Build target
run: cmake --build ${{github.workspace}}/build --target qjs run-test262 -j 8

- name: Test
run: ./bin/qjs -e 'console.log("Hello, World!")'

0 comments on commit 3b682d1

Please sign in to comment.