Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 68 additions & 38 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,104 @@
name: Setup Environment
description: Setup environment variables for the GitHub Actions workflow.
description: Setup Node, dependencies, and optional Electron binaries for GitHub Actions jobs.

inputs:
install-dependencies:
description: Run a lockfile install (npm ci / yarn / pnpm). Set false when node_modules was restored from artifacts.
required: false
default: 'true'
install-electron:
description: Restore/cache Electron binaries and run the Electron postinstall.
required: false
default: 'false'

runs:
using: 'composite'
steps:
- name: Detect package manager
id: pm
shell: bash
run: |
if [ -f pnpm-lock.yaml ]; then
echo "pm=pnpm" >> "$GITHUB_OUTPUT"
echo "lockfile=pnpm-lock.yaml" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ -f yarn.lock ]; then
echo "pm=yarn" >> "$GITHUB_OUTPUT"
echo "lockfile=yarn.lock" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ -f package-lock.json ]; then
echo "pm=npm" >> "$GITHUB_OUTPUT"
echo "lockfile=package-lock.json" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "pm=pnpm" >> "$GITHUB_OUTPUT"
echo "lockfile=pnpm-lock.yaml" >> "$GITHUB_OUTPUT"

- name: Setup Node from .nvmrc
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: ${{ steps.pm.outputs.pm }}
cache-dependency-path: ${{ steps.pm.outputs.lockfile }}

- name: Enable corepack
shell: bash
run: corepack enable || true

- name: Detect package manager
id: pm
shell: bash
run: |
if [ -f pnpm-lock.yaml ]; then echo "pm=pnpm" >> $GITHUB_OUTPUT; exit 0; fi
if [ -f yarn.lock ]; then echo "pm=yarn" >> $GITHUB_OUTPUT; exit 0; fi
if [ -f package-lock.json ]; then echo "pm=npm" >> $GITHUB_OUTPUT; exit 0; fi
echo "pm=pnpm" >> $GITHUB_OUTPUT

- name: Install dependencies
if: inputs.install-dependencies == 'true'
shell: bash
run: |
PM="${{ steps.pm.outputs.pm }}"
if [ "$PM" = "pnpm" ]; then pnpm install --frozen-lockfile; fi
if [ "$PM" = "yarn" ]; then yarn install --frozen-lockfile; fi
if [ "$PM" = "npm" ]; then npm ci; fi

- name: Set Cypress cache folder
id: cypress-cache
- name: Assert node_modules present
if: inputs.install-dependencies != 'true'
shell: bash
run: |
if [ ! -d node_modules ]; then
echo "::error::install-dependencies is false but node_modules is missing. Restore build artifacts before setup-env, or set install-dependencies to true."
exit 1
fi

- name: Apply patches (artifact restore)
if: inputs.install-dependencies != 'true'
shell: bash
run: |
if [ -d patches ]; then
npx patch-package
fi

- name: Set Electron cache folder
if: inputs.install-electron == 'true'
id: electron-cache
shell: bash
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
CYPRESS_CACHE="$USERPROFILE/.cache/Cypress"
ELECTRON_CACHE="$USERPROFILE/.cache/electron"
else
CYPRESS_CACHE="$HOME/.cache/Cypress"
ELECTRON_CACHE="$HOME/.cache/electron"
fi
echo "folder=$CYPRESS_CACHE" >> $GITHUB_OUTPUT
echo "CYPRESS_CACHE_FOLDER=$CYPRESS_CACHE" >> $GITHUB_ENV
echo "folder=$ELECTRON_CACHE" >> "$GITHUB_OUTPUT"
echo "ELECTRON_CACHE=$ELECTRON_CACHE" >> "$GITHUB_ENV"

- name: Restore Cypress cache
- name: Restore Electron cache
if: inputs.install-electron == 'true'
uses: actions/cache@v5
with:
path: |
${{ steps.cypress-cache.outputs.folder }}
node_modules/.cache/Cypress
key: ${{ runner.os }}-cypress-${{ hashFiles('**/pnpm-lock.yaml', '**/yarn.lock', '**/package-lock.json') }}
path: ${{ steps.electron-cache.outputs.folder }}
key: ${{ runner.os }}-electron-${{ hashFiles('**/pnpm-lock.yaml', '**/yarn.lock', '**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-cypress-

- name: Cypress binary install
shell: bash
env:
CYPRESS_CACHE_FOLDER: ${{ steps.cypress-cache.outputs.folder }}
run: |
PM="${{ steps.pm.outputs.pm }}"
if [ "$PM" = "pnpm" ]; then pnpm exec cypress install || true; fi
if [ "$PM" = "yarn" ]; then yarn run -s cypress install || yarn dlx cypress install || true; fi
if [ "$PM" = "npm" ]; then npx --yes cypress install || true; fi
${{ runner.os }}-electron-

- name: Electron binary install
if: inputs.install-electron == 'true'
shell: bash
working-directory: ./node_modules/electron
env:
ELECTRON_CACHE: ${{ steps.electron-cache.outputs.folder }}
run: npm run postinstall || node install.js || true

- name: Patch package
shell: bash
run: |
npm install -g patch-package
patch-package
21 changes: 19 additions & 2 deletions .github/actions/setup-windows-build-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,26 @@ description: Setup Windows build environment for the GitHub Actions workflow.
runs:
using: 'composite'
steps:
- name: Enable i386 architecture
shell: bash
run: sudo dpkg --add-architecture i386

- name: Cache apt archives
uses: actions/cache@v5
with:
path: ${{ github.workspace }}/.apt-archives
key: ${{ runner.os }}-${{ runner.arch }}-apt-wine-mono-xvfb-v1

- name: Install Wine, Mono, Xvfb and zip tools
shell: bash
run: |
sudo dpkg --add-architecture i386
set -euo pipefail
APT_ARCHIVES="${{ github.workspace }}/.apt-archives"
mkdir -p "$APT_ARCHIVES"
sudo apt-get update
sudo apt-get install -y wine64 wine32 mono-complete xvfb zip unzip
sudo apt-get install -y \
-o "Dir::Cache::Archives=$APT_ARCHIVES" \
-o APT::Keep-Downloaded-Packages=true \
wine64 wine32 mono-complete xvfb zip unzip
# actions/cache must be able to read archives written by apt (root).
sudo chown -R "$(id -u):$(id -g)" "$APT_ARCHIVES"
16 changes: 16 additions & 0 deletions .github/workflows/pull-request-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-env
with:
install-dependencies: 'false'

- name: Build API container images
run: |
Expand Down Expand Up @@ -397,6 +399,8 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-env
with:
install-dependencies: 'false'

- name: Build Worker container images
run: |
Expand Down Expand Up @@ -439,6 +443,8 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-env
with:
install-dependencies: 'false'

- name: Build Server container images
run: |
Expand Down Expand Up @@ -534,6 +540,8 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-env
with:
install-dependencies: 'false'

- name: Build binaries
run: npx nx affected --target=scripts-binary --parallel=3
Expand All @@ -559,6 +567,8 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-env
with:
install-dependencies: 'false'

- name: Install OpenAPI Generator CLI
run: |
Expand Down Expand Up @@ -590,6 +600,9 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-env
with:
install-dependencies: 'false'
install-electron: 'true'

- name: Build binaries
env:
Expand Down Expand Up @@ -631,6 +644,9 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-env
with:
install-dependencies: 'false'
install-electron: 'true'

- name: Setup Windows build environment
uses: ./.github/actions/setup-windows-build-env
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-env
with:
install-dependencies: 'false'

- name: 'Login to container registry'
uses: docker/login-action@v4
Expand Down Expand Up @@ -156,6 +158,8 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-env
with:
install-dependencies: 'false'

- name: 'Login to container registry'
uses: docker/login-action@v4
Expand Down Expand Up @@ -203,6 +207,8 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-env
with:
install-dependencies: 'false'

- name: 'Login to container registry'
uses: docker/login-action@v4
Expand Down Expand Up @@ -250,6 +256,8 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-env
with:
install-dependencies: 'false'

- name: Configure npm for GitHub Packages
run: |
Expand Down Expand Up @@ -294,6 +302,9 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-env
with:
install-dependencies: 'false'
install-electron: 'true'

- name: Build binaries
env:
Expand Down Expand Up @@ -342,6 +353,9 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-env
with:
install-dependencies: 'false'
install-electron: 'true'

- name: Setup Windows build environment
uses: ./.github/actions/setup-windows-build-env
Expand Down
Loading