diff --git a/.github/workflows/application-js-cloudflare-feature-closed.yml b/.github/workflows/application-js-cloudflare-feature-closed.yml index b7fcefc..a3ca582 100644 --- a/.github/workflows/application-js-cloudflare-feature-closed.yml +++ b/.github/workflows/application-js-cloudflare-feature-closed.yml @@ -5,7 +5,7 @@ on: inputs: environment: description: 'Deployment Environment' - type: environment + type: string required: true appName: type: string diff --git a/.github/workflows/application-js-cloudflare-feature.yml b/.github/workflows/application-js-cloudflare-feature.yml index 494e591..3cf4a3a 100644 --- a/.github/workflows/application-js-cloudflare-feature.yml +++ b/.github/workflows/application-js-cloudflare-feature.yml @@ -5,7 +5,7 @@ on: inputs: environment: description: 'Deployment Environment' - type: environment + type: string required: true ref: type: string @@ -121,9 +121,6 @@ jobs: url: "https://${{ github.ref_name }}.dev.zeta.house" run: | echo 'Perform service deployment for feature' - echo "$SECRET1" - echo "$SECRET2" - echo "$SECRET3" nix develop .#ci --command bash -c $' npm run deploy -- \ --feature "$GITHUB_REF_NAME" \ diff --git a/.github/workflows/application-js-cloudflare-master.yml b/.github/workflows/application-js-cloudflare-master.yml index 79404a0..a993baf 100644 --- a/.github/workflows/application-js-cloudflare-master.yml +++ b/.github/workflows/application-js-cloudflare-master.yml @@ -5,7 +5,7 @@ on: inputs: environment: description: 'Deployment Environment' - type: environment + type: string required: true ref: type: string diff --git a/.github/workflows/application-js-cloudflare-staging.yml b/.github/workflows/application-js-cloudflare-staging.yml index cc69a45..60cc507 100644 --- a/.github/workflows/application-js-cloudflare-staging.yml +++ b/.github/workflows/application-js-cloudflare-staging.yml @@ -5,7 +5,7 @@ on: inputs: environment: description: 'Deployment Environment' - type: environment + type: string required: true ref: type: string diff --git a/.github/workflows/library-js-staging.yml b/.github/workflows/library-js-staging.yml index 71675ef..4e92368 100644 --- a/.github/workflows/library-js-staging.yml +++ b/.github/workflows/library-js-staging.yml @@ -92,36 +92,10 @@ jobs: include: - platform: linux os: ubuntu-latest - env: {} - script: | - nix develop .#ci --command bash -c $' - npm test -- --ci --coverage - npm run bench --if-present - ' - platform: windows - os: windows-latest - env: {} - script: | - mkdir -Force "$CI_PROJECT_DIR/tmp" - Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 - ./scripts/choco-install.ps1 - refreshenv - npm install --ignore-scripts - $env:Path = "$(npm root)\.bin;" + $env:Path - npm test -- --ci --coverage - npm run bench --if-present + os: windows-2022 - platform: macos os: macos-latest - env: {} - script: | - mkdir -p "$CI_PROJECT_DIR/tmp" - eval "$(brew shellenv)" - ./scripts/brew-install.sh - hash -r - npm install --ignore-scripts - export PATH="$(npm root)/.bin:$PATH" - npm test -- --ci --coverage - npm run bench --if-present steps: - uses: actions/checkout@v4 - if: matrix.platform == 'linux' @@ -130,9 +104,47 @@ jobs: with: name: dist path: ./dist - - name: Build - env: ${{ matrix.env }} - run: ${{ matrix.script }} + - name: Windows Bootstrap + if: matrix.platform == 'windows' + shell: pwsh + run: | + mkdir -Force "$CI_PROJECT_DIR/tmp" + ./scripts/choco-install.ps1 + where.exe node + where.exe npm + node -v + npm -v + - name: Build (Windows) + if: matrix.platform == 'windows' + shell: pwsh + run: | + npm install --ignore-scripts + $env:Path = "$(npm root)\.bin;" + $env:Path + where.exe node + where.exe npm + node -v + npm -v + npm test -- --ci --coverage + npm run bench --if-present + - name: Build (Linux) + if: matrix.platform == 'linux' + run: | + nix develop .#ci --command bash -c $' + npm test -- --ci --coverage + npm run bench --if-present + ' + - name: Build (macOS) + if: matrix.platform == 'macos' + shell: bash + run: | + mkdir -p "$CI_PROJECT_DIR/tmp" + eval "$(brew shellenv)" + ./scripts/brew-install.sh + hash -r + npm install --ignore-scripts + export PATH="$(npm root)/.bin:$PATH" + npm test -- --ci --coverage + npm run bench --if-present - name: Upload JUnit Report if: success() || failure() uses: actions/upload-artifact@v4 diff --git a/.github/workflows/native-library-js-feature.yml b/.github/workflows/native-library-js-feature.yml index 7a2e41a..a3975ce 100644 --- a/.github/workflows/native-library-js-feature.yml +++ b/.github/workflows/native-library-js-feature.yml @@ -12,6 +12,8 @@ jobs: contents: read steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master - name: Run linting run: | @@ -28,6 +30,8 @@ jobs: actions: write steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master - name: Run build run: | @@ -50,6 +54,8 @@ jobs: checks: write steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master - name: Run tests run: | @@ -82,6 +88,8 @@ jobs: actions: write steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master - name: Run bench run: | diff --git a/.github/workflows/native-library-js-staging.yml b/.github/workflows/native-library-js-staging.yml index d1615f8..2ff19d1 100644 --- a/.github/workflows/native-library-js-staging.yml +++ b/.github/workflows/native-library-js-staging.yml @@ -23,12 +23,13 @@ jobs: contents: read steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master - name: Run linting run: | nix develop .#ci --command bash -c $' npm run lint - npm run lint-shell ' # Create the merge PR @@ -40,6 +41,8 @@ jobs: pull-requests: write steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - name: Create Pull Request from Staging to Master env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -64,6 +67,8 @@ jobs: actions: write steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master - name: Run build run: | @@ -88,55 +93,70 @@ jobs: actions: write checks: write strategy: - fail-fast: true + fail-fast: false matrix: include: - platform: linux os: ubuntu-latest - env: {} - script: | - nix develop .#ci --command bash -c $' - npm run prebuild --verbose - npm test -- --ci --coverage - npm run bench --if-present - ' - platform: windows - os: windows-latest - env: {} - script: | - mkdir -Force "$CI_PROJECT_DIR/tmp" - Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 - ./scripts/choco-install.ps1 - refreshenv - npm install --ignore-scripts - $env:Path = "$(npm root)\.bin;" + $env:Path - npm run prebuild --verbose - npm test -- --ci --coverage - npm run bench --if-present + os: windows-2022 - platform: macos os: macos-latest - env: {} - script: | - mkdir -p "$CI_PROJECT_DIR/tmp" - eval "$(brew shellenv)" - ./scripts/brew-install.sh - hash -r - npm install --ignore-scripts - export PATH="$(npm root)/.bin:$PATH" - npm run prebuild --verbose - npm test -- --ci --coverage - npm run bench --if-present steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - if: matrix.platform == 'linux' uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master - uses: actions/download-artifact@v4 with: name: dist path: ./dist - - name: Build - env: ${{ matrix.env }} - run: ${{ matrix.script }} + - name: Windows Bootstrap + if: matrix.platform == 'windows' + shell: pwsh + run: | + mkdir -Force "$CI_PROJECT_DIR/tmp" + ./scripts/choco-install.ps1 + where.exe node + where.exe npm + node -v + npm -v + - name: Build (Windows) + if: matrix.platform == 'windows' + shell: pwsh + run: | + npm install --ignore-scripts + $env:Path = "$(npm root)\.bin;" + $env:Path + where.exe node + where.exe npm + node -v + npm -v + npm run prebuild --verbose + npm test -- --ci --coverage + npm run bench --if-present + - name: Build (Linux) + if: matrix.platform == 'linux' + run: | + nix develop .#ci --command bash -c $' + npm run prebuild --verbose + npm test -- --ci --coverage + npm run bench --if-present + ' + - name: Build (macOS) + if: matrix.platform == 'macos' + shell: bash + run: | + mkdir -p "$CI_PROJECT_DIR/tmp" + eval "$(brew shellenv)" + ./scripts/brew-install.sh + export PYTHON=$(brew --prefix python@3.10)/bin/python3.10 + hash -r + npm install --ignore-scripts + export PATH="$(npm root)/.bin:$PATH" + npm run prebuild --verbose + npm test -- --ci --coverage + npm run bench --if-present - name: Upload JUnit Report if: success() || failure() uses: actions/upload-artifact@v4 @@ -180,6 +200,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + submodules: 'recursive' token: ${{ secrets.GH_TOKEN }} - name: Merge Pull Request from Staging to Master env: diff --git a/.github/workflows/native-library-js-tag-gyp.yml b/.github/workflows/native-library-js-tag-gyp.yml new file mode 100644 index 0000000..5025739 --- /dev/null +++ b/.github/workflows/native-library-js-tag-gyp.yml @@ -0,0 +1,243 @@ +name: "CI / Library JS Tag" + +on: + workflow_call: + secrets: + NPM_TOKEN: + required: true + +jobs: + # Lint the code + tag-lint: + name: "Tag / Lint" + runs-on: ubuntu-latest + permissions: + contents: read + actions: write + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master + - name: Run linting + run: | + nix develop .#ci --command bash -c $' + npm run lint + ' + + # Build the distribution - JS is platform-agnostic + tag-build: + name: "Tag / Build" + runs-on: ubuntu-latest + permissions: + contents: read + actions: write + needs: tag-lint + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master + - name: Run build + run: | + nix develop .#ci --command bash -c $' + npm run build --verbose + ' + - name: Upload Build + uses: actions/upload-artifact@v4 + with: + name: dist + path: ./dist + + tag-platforms: + name: "Tag / Platforms" + needs: + - tag-build + runs-on: ${{ matrix.os }} + permissions: + contents: read + actions: write + checks: write + strategy: + fail-fast: false + matrix: + include: + - platform: linux + os: ubuntu-latest + - platform: windows + os: windows-2022 + - platform: macos + os: macos-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - if: matrix.platform == 'linux' + uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master + - uses: actions/download-artifact@v4 + with: + name: dist + path: ./dist + - name: Windows Bootstrap + if: matrix.platform == 'windows' + shell: pwsh + run: | + mkdir -Force "$CI_PROJECT_DIR/tmp" + ./scripts/choco-install.ps1 + where.exe node + where.exe npm + node -v + npm -v + - name: Build (Windows) + if: matrix.platform == 'windows' + shell: pwsh + env: + npm_config_arch: "x64" + RUST_BACKTRACE: "1" + LIBCLANG_PATH: "C:\\Program Files\\LLVM\\bin" + run: | + npm install --ignore-scripts + $env:Path = "$(npm root)\.bin;" + $env:Path + where.exe node + where.exe npm + node -v + npm -v + npm run prebuild --verbose -- --production + npm test -- --ci --coverage + npm run bench + - name: Build (Linux) + if: matrix.platform == 'linux' + env: + npm_config_arch: "x64" + RUST_BACKTRACE: "1" + run: | + nix develop .#ci --command bash -c $' + npm run prebuild --verbose -- --production + npm test -- --ci --coverage + npm run bench + ' + - name: Build (macOS) + if: matrix.platform == 'macos' + shell: bash + run: | + eval "$(brew shellenv)" + ./scripts/brew-install.sh + export PYTHON=$(brew --prefix python@3.10)/bin/python3.10 + hash -r + npm install --ignore-scripts + export PATH="$(npm root)/.bin:$PATH" + npm run prebuild --verbose -- --production + npm test -- --ci --coverage + npm run bench + - uses: actions/upload-artifact@v4 + with: + name: prebuild-${{ matrix.platform }} + path: ./prebuilds + + + # Publish the prerelease + tag-prerelease: + name: "Tag / Pre-release" + runs-on: ubuntu-latest + concurrency: + group: tag-prerelease + cancel-in-progress: false + needs: + - tag-platforms + permissions: + contents: write + if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-') + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master + - uses: actions/download-artifact@v4 + with: + pattern: prebuild* + path: prebuilds + merge-multiple: true + - name: Publishing library prerelease + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc + nix develop .#ci --command bash -c $' + npm publish --tag prerelease --access public + ' + for d in prebuilds/*; do + tar \ + --create \ + --verbose \ + --file="prebuilds/$(basename $d).tar" \ + --directory=prebuilds \ + "$(basename $d)" + done + nix develop .#ci --command bash -c $' + gh release \ + create "$GITHUB_REF_NAME" \ + prebuilds/*.tar \ + --title "$GITHUB_REF_NAME-$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \ + --notes "" \ + --prerelease \ + --target staging \ + --repo "$GITHUB_REPOSITORY" + ' + - name: Remove `.npmrc` + if: success() || failure() + run: | + rm -f ./.npmrc + + # Publish the release + tag-release: + name: "Tag / Release" + runs-on: ubuntu-latest + concurrency: + group: tag-release + cancel-in-progress: false + needs: + - tag-platforms + permissions: + contents: write + if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master + - uses: actions/download-artifact@v4 + with: + pattern: prebuild* + path: prebuilds + merge-multiple: true + - name: Publishing library release + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc + nix develop .#ci --command bash -c $' + npm publish --access public + ' + for d in prebuilds/*; do + tar \ + --create \ + --verbose \ + --file="prebuilds/$(basename $d).tar" \ + --directory=prebuilds \ + "$(basename $d)" + done + nix develop .#ci --command bash -c $' + gh release \ + create "$GITHUB_REF_NAME" \ + prebuilds/*.tar \ + --title "$GITHUB_REF_NAME-$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \ + --notes "" \ + --target master \ + --repo "$GITHUB_REPOSITORY" + ' + - name: Remove `.npmrc` + if: success() || failure() + run: | + rm -f ./.npmrc diff --git a/.github/workflows/native-library-js-tag.yml b/.github/workflows/native-library-js-tag.yml index 7304b60..141da76 100644 --- a/.github/workflows/native-library-js-tag.yml +++ b/.github/workflows/native-library-js-tag.yml @@ -16,12 +16,13 @@ jobs: actions: write steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master - name: Run linting run: | nix develop .#ci --command bash -c $' npm run lint - npm run lint-shell ' # Build the distribution - JS is platform-agnostic @@ -34,6 +35,8 @@ jobs: needs: tag-lint steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master - name: Run build run: | @@ -61,62 +64,86 @@ jobs: include: - platform: linux os: ubuntu-latest - env: - npm_config_arch: "x64" - RUST_BACKTRACE: "1" - script: | - nix develop .#ci --command bash -c $' - npm run prebuild --verbose -- --production - npm test -- --ci --coverage - npm run bench - ' - platform: windows - os: windows-latest - env: - npm_config_arch: "x64" - RUST_BACKTRACE: "1" - LIBCLANG_PATH: "C:\\Program Files\\LLVM\\bin" - script: | - mkdir -Force "$CI_PROJECT_DIR/tmp" - Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 - ./scripts/choco-install.ps1 - refreshenv - npm install --ignore-scripts - $env:Path = "$(npm root)\.bin;" + $env:Path - npm run prebuild --verbose -- --production - npm test -- --ci --coverage - npm run bench + os: windows-2022 - platform: macos os: macos-latest - env: - RUST_BACKTRACE: "1" - script: | - eval "$(brew shellenv)" - ./scripts/brew-install.sh - hash -r - npm install --ignore-scripts - export PATH="$(npm root)/.bin:$PATH" - export PATH="$HOME/.cargo/bin:$PATH" - npm run prebuild --verbose -- --arch x64 --production - npm run prebuild --verbose -- --arch arm64 --production - lipo -create -output prebuild/quic-darwin-x64+arm64.node prebuild/quic-darwin-arm64.node prebuild/quic-darwin-x64.node - rm -rf node_modules/@matrixai/quic-* - npm test -- --ci --coverage - npm run bench steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - if: matrix.platform == 'linux' uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master - - uses: actions/setup-node@v4 - with: - node-version: '20' - uses: actions/download-artifact@v4 with: name: dist path: ./dist - - name: Build - env: ${{ matrix.env }} - run: ${{ matrix.script }} + - name: Windows Bootstrap + if: matrix.platform == 'windows' + shell: pwsh + run: | + mkdir -Force "$CI_PROJECT_DIR/tmp" + ./scripts/choco-install.ps1 + where.exe node + where.exe npm + node -v + npm -v + - name: Build (Windows) + if: matrix.platform == 'windows' + shell: pwsh + env: + npm_config_arch: "x64" + RUST_BACKTRACE: "1" + LIBCLANG_PATH: "C:\\Program Files\\LLVM\\bin" + run: | + npm install --ignore-scripts + $env:Path = "$(npm root)\.bin;" + $env:Path + where.exe node + where.exe npm + node -v + npm -v + npm run prebuild --verbose -- --production + npm test -- --ci --coverage + npm run bench + - name: Build (Linux) + if: matrix.platform == 'linux' + env: + npm_config_arch: "x64" + RUST_BACKTRACE: "1" + run: | + nix develop .#ci --command bash -c $' + npm run prebuild --verbose -- --production + npm test -- --ci --coverage + npm run bench + ' + - name: Build (macOS) + if: matrix.platform == 'macos' + shell: bash + run: | + eval "$(brew shellenv)" + ./scripts/brew-install.sh + export PYTHON=$(brew --prefix python@3.10)/bin/python3.10 + hash -r + npm install --ignore-scripts + export PATH="$(npm root)/.bin:$PATH" + export PATH="$HOME/.cargo/bin:$PATH" + echo "Prebuilding for darwin-x64" + npm run prebuild --verbose -- --arch x64 --production + echo "Prebuilding for darwin-arm64" + npm run prebuild --verbose -- --arch arm64 --production + echo "Creating universal binary" + for f in prebuild/*-darwin-arm64.node; do + prefix=$(basename "$f" | sed -E 's/-darwin-arm64\.node$//') + lipo -create \ + -output "prebuild/${prefix}-darwin-x64+arm64.node" \ + "prebuild/${prefix}-darwin-arm64.node" \ + "prebuild/${prefix}-darwin-x64.node" + done + rm -rf node_modules/@matrixai/*-* + echo "Running tests" + npm test -- --ci --coverage + echo "Running benchmarks" + npm run bench - uses: actions/upload-artifact@v4 with: name: prebuild-${{ matrix.platform }} @@ -137,6 +164,8 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-') steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master - uses: actions/download-artifact@v4 with: @@ -189,6 +218,8 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master - uses: actions/download-artifact@v4 with: diff --git a/README.md b/README.md index 6d9e12f..bce300d 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,19 @@ Ensure that this repository is mirrored from GitLab to GitHub. This is where we centralized re-usable workflows for GitHub actions. Workflows are grouped together into different kinds of projects. +### Windows runners and Node.js + +On GitHub-hosted Windows runners it is common to have multiple Node versions on `PATH` (for example Node 22 may be preinstalled). If a workflow calls `refreshenv` / `Update-SessionEnvironment` after selecting Node, it can rebuild `PATH` and cause `npm.cmd` to come from a different Node installation than `node.exe`. + +To avoid the Node/npm mismatch: + +* Windows jobs are pinned to `windows-2022`. +* Windows execution is split into two steps: + 1. **Bootstrap** runs repo-local `./scripts/choco-install.ps1` and prints: + `where.exe node`, `where.exe npm`, `node -v`, `npm -v`, `npm exec --yes node -v`. + 2. **Build/Test** runs npm commands in a separate step so `$GITHUB_PATH` updates from the bootstrap step are applied deterministically. +* Reusable workflows in this repository do not use `actions/setup-node` for Windows; they delegate Node selection to the downstream repo’s `./scripts/choco-install.ps1`. + * library-js - TS/JS projects that produce libraries as NPM packages. - feature - for feature branches - staging - for staging branches