diff --git a/.github/workflows/publish-npm.yaml b/.github/workflows/publish-npm.yaml index 04594b30..102f0f74 100644 --- a/.github/workflows/publish-npm.yaml +++ b/.github/workflows/publish-npm.yaml @@ -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:master 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 @@ -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 diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 3e744171..7c60c583 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -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] @@ -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' @@ -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 @@ -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