current commit
261102.5 · meta: bump cachix/install-nix-action from 31.11.1 to 31.11.3
name: Build Node.js (shared libraries)

on:
  workflow_call:
    inputs:
      runner:
        description: The runner to use for the job.
        required: true
        type: string
      extra-nix-flags:
        description: Additional CLI arguments appended to the nix-shell invocation.
        required: false
        type: string
        default: ''
      with-sccache:
        description: Whether to enable sccache
        required: false
        type: boolean
        default: false
      v8-nar:
        description: An optional name for the NAR archive for V8 that needs to be downloaded
        required: false
        type: string
        default: ''
      pkcs11-store-test:
        description: Whether to enable the PKCS#11-backed crypto STORE test
        required: false
        type: boolean
        default: false
    secrets:
      CACHIX_AUTH_TOKEN:
        description: Cachix auth token for nodejs.cachix.org.
        required: false

permissions: {}

env:
  FLAKY_TESTS: keep_retrying

jobs:
  build:
    runs-on: ${{ inputs.runner }}
    steps:
      - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333  # v8.0.2
        with:
          path: tarballs
          pattern: '*.tar.gz'
          merge-multiple: true

      - name: Extract tarball
        shell: bash
        run: |
          tar xzf tarballs/*.tar.gz -C "$RUNNER_TEMP"
          echo "TAR_DIR=$RUNNER_TEMP/$(basename tarballs/*.tar.gz .tar.gz)" >> "$GITHUB_ENV"

      - uses: cachix/install-nix-action@75c75c31ebece974e48ebc36b4ad125bd97bd97b  # v31.11.3
        with:
          extra_nix_config: sandbox = true

      - uses: cachix/cachix-action@38b082610b782e7e93e209c35fd730d399dee866  # v17
        with:
          name: nodejs
          authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

      - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333  # v8.0.2
        if: inputs.v8-nar
        with:
          name: ${{ inputs.v8-nar }}

      - name: Configure sccache
        if: inputs.with-sccache
        uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3  # v9.0.0
        with:
          script: |
            core.exportVariable('SCCACHE_GHA_ENABLED', 'on');
            core.exportVariable('ACTIONS_CACHE_SERVICE_V2', 'on');
            core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || '');
            core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
            core.exportVariable('NIX_SCCACHE', '(import <nixpkgs> {}).sccache');

      - name: Build Node.js and run tests
        shell: bash
        run: |
          nix-shell \
            -I "nixpkgs=$TAR_DIR/tools/nix/pkgs.nix" \
            --pure --keep TAR_DIR --keep FLAKY_TESTS \
            --keep SCCACHE_GHA_ENABLED --keep ACTIONS_CACHE_SERVICE_V2 --keep ACTIONS_RESULTS_URL --keep ACTIONS_RUNTIME_TOKEN \
            --arg ccache "${NIX_SCCACHE:-null}" \
            --arg pkcs11 ${{ inputs.pkcs11-store-test }} \
            ${{ inputs.extra-nix-flags }} \
            --run '
                make -C "$TAR_DIR" run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
            ' "$TAR_DIR/tools/nix/ci-shell.nix"