Skip to content

Commit

Permalink
Fix BYOND cache not being handled properly in CI (#5043)
Browse files Browse the repository at this point in the history
* Fix BYOND cache not being handled properly in CI

* setup_caches -> setup_byond_cache

* Move `setup_byond_cache` into `collect_data` task
  • Loading branch information
LikeLakers2 authored Jan 24, 2025
1 parent 3f25709 commit 59bfd37
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 24 deletions.
51 changes: 51 additions & 0 deletions .github/actions/restore_or_install_byond/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This is a reusable workflow to restore BYOND from a cache, or to install it otherwise.
name: Restore or Install BYOND
description: Attempts to restore a specified BYOND version from cache; if it can't, it installs it.

inputs:
major:
description: "The major BYOND version to install. Defaults to the BYOND_MAJOR specified in `dependencies.sh`."
required: false
type: string
minor:
description: "The minor BYOND version to install. Defaults to the BYOND_MINOR specified in `dependencies.sh`."
required: false
type: string

runs:
using: composite
steps:
- name: Configure BYOND version from inputs
if: ${{ inputs.major }}
shell: bash
run: |
echo "BYOND_MAJOR=${{ inputs.major }}" >> $GITHUB_ENV
echo "BYOND_MINOR=${{ inputs.minor }}" >> $GITHUB_ENV
- name: Configure BYOND version from dependencies.sh
if: ${{ !inputs.major }}
shell: bash
run: |
source dependencies.sh
echo "BYOND_MAJOR=$BYOND_MAJOR" >> $GITHUB_ENV
echo "BYOND_MINOR=$BYOND_MINOR" >> $GITHUB_ENV
# The use of `actions/cache/restore` and `actions/cache/save` here is deliberate, as we want to
# save the BYOND install to a cache as early as possible. If we used just `actions/cache`, it
# would only attempt to save the cache at the end of a job. This ensures that if a workflow run
# is cancelled, we already have a cache to restore from.
- name: Restore BYOND cache
id: restore_byond_cache
uses: actions/cache/restore@v4
with:
path: ~/BYOND
key: ${{ runner.os }}-byond-${{ env.BYOND_MAJOR }}-${{ env.BYOND_MINOR }}
- name: Install BYOND
if: ${{ !steps.restore_byond_cache.outputs.cache-hit }}
shell: bash
run: bash tools/ci/install_byond.sh
- name: Save BYOND cache
if: ${{ !steps.restore_byond_cache.outputs.cache-hit }}
uses: actions/cache/save@v4
with:
path: ~/BYOND
key: ${{ steps.restore_byond_cache.outputs.cache-primary-key }}
8 changes: 2 additions & 6 deletions .github/workflows/autowiki.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,16 @@ jobs:
- name: Checkout
if: steps.secrets_set.outputs.SECRETS_ENABLED
uses: actions/checkout@v4
- name: Restore BYOND cache
- name: Install BYOND
if: steps.secrets_set.outputs.SECRETS_ENABLED
uses: actions/cache@v4
with:
path: ~/BYOND
key: ${{ runner.os }}-byond-${{ hashFiles('dependencies.sh') }}
uses: ./.github/actions/restore_or_install_byond
- name: Install rust-g
if: steps.secrets_set.outputs.SECRETS_ENABLED
run: |
bash tools/ci/install_rust_g.sh
- name: Compile and generate Autowiki files
if: steps.secrets_set.outputs.SECRETS_ENABLED
run: |
bash tools/ci/install_byond.sh
source $HOME/BYOND/byond/bin/byondsetup
tools/build/build --ci autowiki
- name: Run Autowiki
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/ci_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Restore BYOND cache
uses: actions/cache@v4
with:
path: ~/BYOND
key: ${{ runner.os }}-byond-${{ hashFiles('dependencies.sh') }}
- name: Restore BYOND from Cache
uses: ./.github/actions/restore_or_install_byond
- name: Compile All Maps
run: |
bash tools/ci/install_byond.sh
source $HOME/BYOND/byond/bin/byondsetup
tools/build/build --ci dm -DCIBUILDING -DCITESTING -DALL_MAPS
- name: Check client Compatibility
Expand All @@ -158,7 +154,7 @@ jobs:
max-required-client-version: ${{needs.collect_data.outputs.max_required_byond_client}}

collect_data:
name: Collect data for other tasks
name: Collect data and setup caches for other tasks
needs: start_gate
runs-on: ubuntu-22.04
timeout-minutes: 5
Expand Down Expand Up @@ -186,6 +182,8 @@ jobs:
#the regex here does not filter out non-numbers because error messages about no input are less helpful then error messages about bad input (which includes the bad input)
run: |
echo "max_required_byond_client=$(grep -Ev '^[[:blank:]]{0,}#{1,}|^[[:blank:]]{0,}$' .github/max_required_byond_client.txt | tail -n1)" >> $GITHUB_OUTPUT
- name: Set up BYOND cache
uses: ./.github/actions/restore_or_install_byond

run_all_tests:
name: Integration Tests
Expand Down
16 changes: 5 additions & 11 deletions .github/workflows/run_integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ jobs:
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v4
- name: Restore BYOND cache
uses: actions/cache@v4
with:
path: ~/BYOND
key: ${{ runner.os }}-byond-${{ hashFiles('dependencies.sh') }}
- name: Setup database
run: |
sudo systemctl start mysql
Expand All @@ -49,15 +44,14 @@ jobs:
- name: Install dreamluau
run: |
bash tools/ci/install_dreamluau.sh
- name: Configure version
run: |
echo "BYOND_MAJOR=${{ inputs.major }}" >> $GITHUB_ENV
echo "BYOND_MINOR=${{ inputs.minor }}" >> $GITHUB_ENV
if: ${{ inputs.major }}
- name: Restore BYOND from Cache
uses: ./.github/actions/restore_or_install_byond
with:
major: ${{ inputs.major }}
minor: ${{ inputs.minor }}
- name: Compile Tests
id: compile_tests
run: |
bash tools/ci/install_byond.sh
source $HOME/BYOND/byond/bin/byondsetup
tools/build/build --ci dm -DCIBUILDING -DANSICOLORS -Werror
- name: Run Tests
Expand Down

0 comments on commit 59bfd37

Please sign in to comment.