TestDataID #17950
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2020 Energinet DataHub A/S | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License2"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: GreenForce Frontend CI | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
BASE_BRANCH: ${{ github.event.pull_request.base.ref }} | |
is-main-branch: ${{ github.ref == 'refs/heads/main' }} | |
is-pull-request: ${{ github.event_name == 'pull_request' }} | |
# keep in sync with "engines.bun" and "volta.bun" in "package.json" | |
BUN_VERSION: 1.1.26 | |
# Nx Cloud | |
NX_BRANCH: ${{ github.event.number }} | |
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} | |
NX_RUN_GROUP: ${{ github.run_id }} | |
# DH E2E | |
# Note: Cypress automatically removes the "CYPRESS_" prefix in CI | |
CYPRESS_DH_E2E_USERNAME: ${{ vars.DH_E2E_U1_USERNAME }} | |
CYPRESS_DH_E2E_PASSWORD: ${{ secrets.DH_E2E_U1_PASSWORD }} | |
CYPRESS_DH_E2E_B2C_URL: https://b2cshresdevwe002.b2clogin.com | |
# See https://github.com/cypress-io/cypress/issues/25357 | |
ELECTRON_EXTRA_LAUNCH_ARGS: --disable-gpu | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- apps/dh/api-dh/** | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: {} | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
# needed for Nx affected command | |
- name: "PR: Check out source code with current branch Git history" | |
if: ${{ env.is-pull-request == 'true' }} | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.head_ref }} | |
# needed for Nx affected command | |
- name: "PR: Fetch base branch Git history" | |
if: ${{ env.is-pull-request == 'true' }} | |
run: git fetch --no-tags origin $BASE_BRANCH | |
- name: "Merge: Check out source code" | |
if: ${{ env.is-pull-request == 'false' }} | |
uses: actions/checkout@v4 | |
- name: Bun setup | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: ${{ env.BUN_VERSION }} | |
- name: Install dependencies | |
run: bun install --frozen-lockfile | |
- name: "PR: Production build of affected products" | |
if: ${{ env.is-pull-request == 'true' }} | |
run: bun run affected:build --base=origin/$BASE_BRANCH | |
- name: "Merge: Production build of all products" | |
if: ${{ env.is-pull-request == 'false' }} | |
run: bun run build | |
e2e: | |
name: End-to-end test | |
runs-on: ubuntu-latest | |
steps: | |
# needed for Nx affected command | |
- name: "PR: Check out source code with current branch Git history" | |
if: ${{ env.is-pull-request == 'true' }} | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.head_ref }} | |
# needed for Nx affected command | |
- name: "PR: Fetch base branch Git history" | |
if: ${{ env.is-pull-request == 'true' }} | |
run: git fetch --no-tags origin $BASE_BRANCH | |
- name: "Merge: Check out source code" | |
if: ${{ env.is-pull-request == 'false' }} | |
uses: actions/checkout@v4 | |
- name: Bun setup | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: ${{ env.BUN_VERSION }} | |
- name: Install dependencies | |
run: bun install --frozen-lockfile | |
- name: "PR: End-to-end test affected products" | |
if: ${{ env.is-pull-request == 'true' }} | |
run: bun run affected:e2e --configuration=ci --base=origin/$BASE_BRANCH | |
- name: Upload artifact | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cypress-e2e | |
path: dist/cypress/apps/ | |
- name: "Merge: End-to-end test all products" | |
if: ${{ env.is-pull-request == 'false' }} | |
run: bun run e2e --configuration=ci | |
format: | |
name: "PR: Format" | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
# needed for Nx affected command | |
- name: Check out source code with current branch Git history | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.head_ref }} | |
# needed for Nx affected command | |
- name: Fetch base branch Git history | |
run: git fetch --no-tags origin $BASE_BRANCH | |
- name: Bun setup | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: ${{ env.BUN_VERSION }} | |
- name: Install dependencies | |
run: bun install --frozen-lockfile | |
- name: Revert postinstall changes | |
run: git reset --hard | |
- name: Format projects and configuration files | |
run: bun run format --base=origin/$BASE_BRANCH | |
- name: Commit formatted files | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add -A || cd . | |
git commit -m "style: format" || cd . | |
git push origin --force-with-lease || cd . | |
- name: Check formatting of projects and configuration files | |
run: bun run format:check --base=origin/$BASE_BRANCH | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
# needed for Nx affected command | |
- name: "PR: Check out source code with current branch Git history" | |
if: ${{ env.is-pull-request == 'true' }} | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.head_ref }} | |
# needed for Nx affected command | |
- name: "PR: Fetch base branch Git history" | |
if: ${{ env.is-pull-request == 'true' }} | |
run: git fetch --no-tags origin $BASE_BRANCH | |
- name: "Merge: Check out source code" | |
if: ${{ env.is-pull-request == 'false' }} | |
uses: actions/checkout@v4 | |
- name: Bun setup | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: ${{ env.BUN_VERSION }} | |
- name: Install dependencies | |
run: bun install --frozen-lockfile | |
- name: Revert postinstall changes | |
run: git reset --hard | |
- name: "PR: Fix affected projects using lint rules" | |
if: ${{ env.is-pull-request == 'true' }} | |
run: bun run affected:lint:fix --base=origin/$BASE_BRANCH | |
- name: "PR: Commit fixed files" | |
if: ${{ env.is-pull-request == 'true' }} | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add -A || cd . | |
git commit -m "style: lint" || cd . | |
git push origin --force-with-lease || cd . | |
- name: "Merge: Lint workspace and all projects" | |
if: ${{ env.is-pull-request == 'false' }} | |
run: bun run lint | |
test: | |
name: Unit and integration test | |
runs-on: ubuntu-latest | |
steps: | |
# needed for Nx affected command | |
- name: "PR: Check out source code with current branch Git history" | |
if: ${{ env.is-pull-request == 'true' }} | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.head_ref }} | |
# needed for Nx affected command | |
- name: "PR: Fetch base branch Git history" | |
if: ${{ env.is-pull-request == 'true' }} | |
run: git fetch --no-tags origin $BASE_BRANCH | |
- name: "Merge: Check out source code" | |
if: ${{ env.is-pull-request == 'false' }} | |
uses: actions/checkout@v4 | |
- name: Bun setup | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: ${{ env.BUN_VERSION }} | |
- name: Install dependencies | |
run: bun install --frozen-lockfile | |
- name: "PR: Test affected projects" | |
if: ${{ env.is-pull-request == 'true' }} | |
run: bun run affected:test --base=origin/$BASE_BRANCH | |
- name: "Merge: Test all projects" | |
if: ${{ env.is-pull-request == 'false' }} | |
run: bun run test | |
componentTests: | |
name: Component test | |
runs-on: ubuntu-latest | |
steps: | |
# needed for Nx affected command | |
- name: "PR: Check out source code with current branch Git history" | |
if: ${{ env.is-pull-request == 'true' }} | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.head_ref }} | |
# needed for Nx affected command | |
- name: "PR: Fetch base branch Git history" | |
if: ${{ env.is-pull-request == 'true' }} | |
run: git fetch --no-tags origin $BASE_BRANCH | |
- name: "Merge: Check out source code" | |
if: ${{ env.is-pull-request == 'false' }} | |
uses: actions/checkout@v4 | |
- name: Bun setup | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: ${{ env.BUN_VERSION }} | |
- name: Install dependencies | |
run: bun install --frozen-lockfile | |
- name: "PR: Test affected projects" | |
if: ${{ env.is-pull-request == 'true' }} | |
run: bun run affected -t component-test --base=origin/$BASE_BRANCH | |
- name: "Merge: Test all projects" | |
if: ${{ env.is-pull-request == 'false' }} | |
run: bun run nx run-many -t component-test | |
- name: Upload artifact | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cypress-component-tests | |
path: dist/cypress/libs/ |