Skip to content

Commit

Permalink
Adjust CI scripts to use musl builds on some days (for testing & deploy)
Browse files Browse the repository at this point in the history
The idea is that that way, we will always test both builds and none will
ever get a bug that remains unnoticed for a long time. Also, annoying
bugs that only appear very rarely or after a long time of running can
be noticed like that as well. Otherwise we wouldn't.
  • Loading branch information
LukasKalbertodt committed Sep 19, 2023
1 parent 75d745e commit d012f3e
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,33 @@ jobs:
steps:
- uses: actions/checkout@v3

# Figure out build mode
- name: Determine build mode
run: |
target_dir="target"
if (( "$(date +%w)" % 2 == 0 )); then
echo "ci_cargo_target=--target=x86_64-unknown-linux-musl" >> $GITHUB_ENV
echo "rust_cache_key=musl" >> $GITHUB_ENV
target_dir="${target_dir}/x86_64-unknown-linux-musl"
else
echo "ci_cargo_target=" >> $GITHUB_ENV
echo "rust_cache_key=gnu" >> $GITHUB_ENV
fi
if [[ "$GITHUB_REPOSITORY" == "elan-ev/tobira" ]] && [ "$GITHUB_REF" == "refs/heads/master" ]; then
echo "ci_cargo_flags=--release" >> $GITHUB_ENV
echo "ci_targetdir=${target_dir}/release" >> $GITHUB_ENV
echo "ci_webpack_flags=production" >> $GITHUB_ENV
else
echo "ci_cargo_flags=--features=embed-in-debug" >> $GITHUB_ENV
echo "ci_targetdir=${target_dir}/debug" >> $GITHUB_ENV
echo "ci_webpack_flags=development" >> $GITHUB_ENV
fi
- name: Restore backend cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ env.rust_cache_key }}
workspaces: backend

# Frontend cache: only the NPM folder is cached, not the node_modules, as
Expand All @@ -52,18 +76,6 @@ jobs:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('frontend/package-lock.json') }}

# Figure out build mode
- name: Determine build mode
run: |
if [[ "$GITHUB_REPOSITORY" == "elan-ev/tobira" ]] && [ "$GITHUB_REF" == "refs/heads/master" ]; then
echo "ci_cargo_flags=--release" >> $GITHUB_ENV
echo "ci_targetdir=target/release" >> $GITHUB_ENV
echo "ci_webpack_flags=production" >> $GITHUB_ENV
else
echo "ci_cargo_flags=--features=embed-in-debug" >> $GITHUB_ENV
echo "ci_targetdir=target/debug" >> $GITHUB_ENV
echo "ci_webpack_flags=development" >> $GITHUB_ENV
fi

# The actual building and testing!
- name: Installing frontend dependencies (npm ci)
Expand All @@ -84,10 +96,10 @@ jobs:

- name: Build backend
working-directory: backend
run: cargo build ${{ env.ci_cargo_flags }}
run: cargo build ${{ env.ci_cargo_flags }} ${{ env.ci_cargo_target }}
- name: Test backend
working-directory: backend
run: cargo test
run: cargo test ${{ env.ci_cargo_target }}

- name: Move Tobira binary
run: mv backend/${{ env.ci_targetdir }}/tobira tobira
Expand Down

0 comments on commit d012f3e

Please sign in to comment.