Skip to content

Commit

Permalink
Improved caching of RDS files, specificity of keys in the testing wor…
Browse files Browse the repository at this point in the history
…kflow.

- fixed the publication workflow to use the new containers and caches.
- rerun the unit tests before publication, just in case.
  • Loading branch information
LTLA committed Oct 13, 2024
1 parent 35bacf5 commit 858485b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 38 deletions.
64 changes: 42 additions & 22 deletions .github/workflows/publish-npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,16 @@ jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
container: ghcr.io/kanaverse/scran.js-docker/builder:master
defaults:
run:
working-directory: /scran.js
container: ghcr.io/kanaverse/emcmake-docker/builder:${{ needs.prepare-version.outputs.version }}

steps:
- name: Get to the right branch
run: |
git fetch --all
git checkout $GITHUB_SHA
# We run the various preparatory steps to ensure that they do, in fact, run.
# This avoids nasty surprises when we actually do want to publish something.
- name: Update node build
run: bash build.sh main

- name: Update browser build
run: bash build.sh browser
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
node-version: 16

- name: Update NPM packages
run: npm i --include=dev
node-version: 18

# We only run the remaining (remote-touching) steps if the version has actually changed.
- name: Extract package versions
Expand All @@ -49,6 +32,43 @@ jobs:
echo "UPDATE_SCRANJS=${update}" >> $GITHUB_ENV
echo "Current version is ${current_version} (published ${old_version})"
- name: Cache installed
if: env.UPDATE_SCRANJS == 1
uses: actions/cache@v4
with:
path: extern/installed
key: deps-${{ hashFiles('extern/**/build.sh') }}-${{ env.IMAGE_VERSION }}

- name: Cache Modules
if: env.UPDATE_SCRANJS == 1
uses: actions/cache@v4
with:
path: '**/node_modules'
key: npm-${{ hashFiles('package.json') }}

- name: Update NPM packages
if: env.UPDATE_SCRANJS == 1
run: npm i --include=dev

- name: Update node build
if: env.UPDATE_SCRANJS == 1
run: bash build.sh main

- name: Update browser build
if: env.UPDATE_SCRANJS == 1
run: bash build.sh browser

- name: Cache RDS files
if: env.UPDATE_SCRANJS == 1
uses: actions/cache@v4
with:
path: tests/rds/*.rds
key: rds-${{ hashFiles('tests/rds/generate.R') }}

- name: Double-checking tests
if: env.UPDATE_SCRANJS == 1
run: CHECK_RDS=1 npm run test

- name: Publish to NPM
if: env.UPDATE_SCRANJS == 1
run: npm publish
Expand Down
34 changes: 18 additions & 16 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4

- name: Cache RDS files
id: cache-rds
uses: actions/cache@v4
with:
path: tests/rds/*.rds
key: rds-${{ hashFiles('tests/rds/generate.R') }}

- name: Build RDS files
if: steps.cache-rds.outputs.cache-hit != 'true'
run: |
cd tests/rds
R -f generate.R
- name: Upload RDS files
uses: actions/upload-artifact@v4
with:
name: rds-files
path: tests/rds/*.rds

build_deps:
runs-on: ubuntu-latest
needs: [prepare-version]
Expand All @@ -51,7 +53,7 @@ jobs:
uses: actions/cache@v4
with:
path: extern/installed
key: deps-${{ hashFiles('**/extern/**/build.sh') }}-${{ env.IMAGE_VERSION }}
key: deps-${{ hashFiles('extern/**/build.sh') }}-${{ env.IMAGE_VERSION }}

- name: Build HDF5
if: steps.installed.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -83,7 +85,7 @@ jobs:
uses: actions/cache@v4
with:
path: '**/node_modules'
key: npm-${{ hashFiles('**/package.json') }}
key: npm-${{ hashFiles('package.json') }}

- name: Update NPM packages
run: npm i --include=dev
Expand All @@ -92,25 +94,25 @@ jobs:
uses: actions/cache@v4
with:
path: extern/installed
key: deps-${{ hashFiles('**/extern/**/build.sh') }}-${{ env.IMAGE_VERSION }}
key: deps-${{ hashFiles('extern/**/build.sh') }}-${{ env.IMAGE_VERSION }}

- name: Cache RDS files
uses: actions/cache@v4
with:
path: tests/rds/*.rds
key: rds-${{ hashFiles('tests/rds/generate.R') }}

- name: Cache node build
id: wasm-build
uses: actions/cache@v4
with:
path: js/wasm
key: wasm-${{ hashFiles('**/build.sh', '**/CMakeLists.txt', '**/src/*') }}-${{ env.IMAGE_VERSION }}
key: wasm-${{ hashFiles('build.sh', 'extern/**/build.sh', 'CMakeLists.txt', 'extern/CMakeLists.txt', 'src/*') }}-${{ env.IMAGE_VERSION }}

- name: Update node build
if: steps.wasm-build.outputs.cache-hit != 'true'
run: bash build.sh main

- name: Download RDS files
uses: actions/download-artifact@v4
with:
name: rds-files
path: tests/rds

- name: Run tests
run: |
export CHECK_RDS=1
Expand Down

0 comments on commit 858485b

Please sign in to comment.