diff --git a/.github/workflows/base-checks.yml b/.github/workflows/base-checks.yaml similarity index 73% rename from .github/workflows/base-checks.yml rename to .github/workflows/base-checks.yaml index 690697f185..2bc32db854 100644 --- a/.github/workflows/base-checks.yml +++ b/.github/workflows/base-checks.yaml @@ -2,9 +2,11 @@ name: Validate on: push: - branches: [main] + branches: + - main pull_request: - branches: [main] + branches: + - main jobs: base-checks: @@ -14,11 +16,11 @@ jobs: matrix: job: [lint, typecheck, test, knip] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Setup node - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: 22.x + node-version: "lts/*" cache: "yarn" cache-dependency-path: "**/yarn.lock" - run: yarn install --immutable --prefer-offline diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yaml similarity index 87% rename from .github/workflows/e2e.yml rename to .github/workflows/e2e.yaml index fa5c89af55..51bf8c4407 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yaml @@ -1,6 +1,7 @@ name: E2E -on: [deployment_status] +on: + - deployment_status jobs: e2e: @@ -12,13 +13,13 @@ jobs: shardIndex: [1, 2, 3, 4] shardTotal: [4] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: # fetch all commits so we can find the branch fetch-depth: 0 - - uses: actions/setup-node@v4 + - uses: actions/setup-node@v6 with: - node-version: 22.x + node-version: "lts/*" cache: "yarn" cache-dependency-path: "**/yarn.lock" - name: Install dependencies @@ -35,7 +36,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload blob report to GitHub Actions Artifacts if: ${{ !cancelled() }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: blob-report-${{ matrix.shardIndex }} path: blob-report diff --git a/.github/workflows/gitlab-mirror.yml b/.github/workflows/gitlab-mirror.yaml similarity index 90% rename from .github/workflows/gitlab-mirror.yml rename to .github/workflows/gitlab-mirror.yaml index 19eedd6543..ad51eed69e 100644 --- a/.github/workflows/gitlab-mirror.yml +++ b/.github/workflows/gitlab-mirror.yaml @@ -1,13 +1,15 @@ name: GitLab Mirror -on: [push, delete] +on: + - push + - delete jobs: to_gitlab: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 - name: Logging diff --git a/.github/workflows/manual-load-test.yml b/.github/workflows/manual-load-test.yaml similarity index 72% rename from .github/workflows/manual-load-test.yml rename to .github/workflows/manual-load-test.yaml index de02884f21..dd14c4c4d8 100644 --- a/.github/workflows/manual-load-test.yml +++ b/.github/workflows/manual-load-test.yaml @@ -27,31 +27,25 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Testing GraphQL - Components if: always() uses: grafana/k6-action@v0.3.1 with: filename: k6/load-tests/graphql/components.js - flags: - --env ENV=${{ env.ENV }} --env ENABLE_GQL_SERVER_SIDE_CACHE=${{ - env.ENABLE_GQL_SERVER_SIDE_CACHE }} + flags: --env ENV=${{ env.ENV }} --env ENABLE_GQL_SERVER_SIDE_CACHE=${{ env.ENABLE_GQL_SERVER_SIDE_CACHE }} - name: Testing GraphQL - Observations if: always() uses: grafana/k6-action@v0.3.1 with: filename: k6/load-tests/graphql/observations.js - flags: - --env ENV=${{ env.ENV }} --env ENABLE_GQL_SERVER_SIDE_CACHE=${{ - env.ENABLE_GQL_SERVER_SIDE_CACHE }} + flags: --env ENV=${{ env.ENV }} --env ENABLE_GQL_SERVER_SIDE_CACHE=${{ env.ENABLE_GQL_SERVER_SIDE_CACHE }} - name: Testing HAR - Edition if: always() uses: grafana/k6-action@v0.3.1 with: filename: k6/load-tests/har/${{ env.ENV }}/edition.js - flags: - --env ENABLE_GQL_SERVER_SIDE_CACHE=${{ - env.ENABLE_GQL_SERVER_SIDE_CACHE }} + flags: --env ENABLE_GQL_SERVER_SIDE_CACHE=${{ env.ENABLE_GQL_SERVER_SIDE_CACHE }} diff --git a/.github/workflows/performance-tests-pr.yml b/.github/workflows/performance-tests-pr.yaml similarity index 96% rename from .github/workflows/performance-tests-pr.yml rename to .github/workflows/performance-tests-pr.yaml index b4c223f032..009607eedb 100644 --- a/.github/workflows/performance-tests-pr.yml +++ b/.github/workflows/performance-tests-pr.yaml @@ -2,10 +2,11 @@ name: GraphQL performance tests (PR) -on: [deployment_status] +on: + - deployment_status env: - SUMMARY: '' + SUMMARY: "" jobs: run_tests: @@ -14,16 +15,16 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Send an HTTP request to start up the server run: | curl -s '${{ github.event.deployment_status.target_url }}/api/graphql' -X 'POST' -H 'Content-Type: application/json' -d '{"operationName":"DataCubeObservations","variables":{"locale":"en","sourceType":"sparql","sourceUrl":"https://lindas.admin.ch/query","cubeFilter":{"iri":"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9","filters":{"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/Kanton":{"type":"single","value":"https://ld.admin.ch/canton/1"}}}},"query":"query DataCubeObservations($sourceType: String!, $sourceUrl: DataSourceUrl!, $locale: String!, $cubeFilter: DataCubeObservationFilter!) { dataCubeObservations(sourceType: $sourceType, sourceUrl: $sourceUrl, locale: $locale, cubeFilter: $cubeFilter) }"}' > /dev/null - name: Download, unzip and install k6 binary run: | - wget https://github.com/grafana/k6/releases/download/v0.49.0/k6-v0.49.0-linux-amd64.tar.gz - tar -xzf k6-v0.49.0-linux-amd64.tar.gz - sudo cp k6-v0.49.0-linux-amd64/k6 /usr/local/bin/k6 - export PATH=$PATH:/usr/local/bin + wget https://github.com/grafana/k6/releases/download/v0.49.0/k6-v0.49.0-linux-amd64.tar.gz + tar -xzf k6-v0.49.0-linux-amd64.tar.gz + sudo cp k6-v0.49.0-linux-amd64/k6 /usr/local/bin/k6 + export PATH=$PATH:/usr/local/bin - name: Run k6 test (iteration 1) run: echo "SUMMARY=${{ env.SUMMARY }}$(k6 run --tag testid=DataCubeComponents --env ENV=PR --env ENDPOINT=${{ github.event.deployment_status.target_url }}/api/graphql --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 --env CHECK_TIMING=true --env WORKSPACE=${{ github.workspace }} --quiet - > $GITHUB_ENV - name: Run k6 test (iteration 2) diff --git a/.github/workflows/performance-tests.yml b/.github/workflows/performance-tests.yaml similarity index 99% rename from .github/workflows/performance-tests.yml rename to .github/workflows/performance-tests.yaml index dd68cbf046..22c52fe497 100644 --- a/.github/workflows/performance-tests.yml +++ b/.github/workflows/performance-tests.yaml @@ -13,13 +13,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Download, unzip and install k6 binary run: | - wget https://github.com/grafana/k6/releases/download/v0.49.0/k6-v0.49.0-linux-amd64.tar.gz - tar -xzf k6-v0.49.0-linux-amd64.tar.gz - sudo cp k6-v0.49.0-linux-amd64/k6 /usr/local/bin/k6 - export PATH=$PATH:/usr/local/bin + wget https://github.com/grafana/k6/releases/download/v0.49.0/k6-v0.49.0-linux-amd64.tar.gz + tar -xzf k6-v0.49.0-linux-amd64.tar.gz + sudo cp k6-v0.49.0-linux-amd64/k6 /usr/local/bin/k6 + export PATH=$PATH:/usr/local/bin - name: Run k6 test (iteration 1) run: K6_PROMETHEUS_RW_USERNAME=${{ secrets.K6_PROMETHEUS_RW_USERNAME }} K6_PROMETHEUS_RW_PASSWORD=${{ secrets.K6_PROMETHEUS_RW_PASSWORD }} K6_PROMETHEUS_RW_SERVER_URL=${{ secrets.K6_PROMETHEUS_RW_SERVER_URL }} K6_PROMETHEUS_RW_TREND_STATS=avg k6 run -o experimental-prometheus-rw --tag testid=DataCubeComponents --env ENV=test --env ENDPOINT=https://test.visualize.admin.ch/api/graphql --env CUBE_IRI=https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9 --env CUBE_LABEL=Photovoltaikanlagen/9 --env CHECK_TIMING=false --env WORKSPACE=${{ github.workspace }} --quiet - Development Environment To start the development environment locally, you need a Postgres database. -There's a [docker-compose.yml](./docker-compose.yml) for this if you have e.g. +There's a [docker-compose.yaml](./docker-compose.yaml) for this if you have e.g. [Docker Desktop](https://www.docker.com/products/docker-desktop) installed. In addition, you need to run a [Node.js](https://nodejs.org/) server on your diff --git a/docker-compose.mitm.yml b/docker-compose.mitm.yaml similarity index 100% rename from docker-compose.mitm.yml rename to docker-compose.mitm.yaml diff --git a/docker-compose.yml b/docker-compose.yaml similarity index 100% rename from docker-compose.yml rename to docker-compose.yaml diff --git a/k6/performance-tests/generate-github-actions.mjs b/k6/performance-tests/generate-github-actions.mjs index 2d5179ced8..68a9920bfd 100644 --- a/k6/performance-tests/generate-github-actions.mjs +++ b/k6/performance-tests/generate-github-actions.mjs @@ -1,6 +1,6 @@ import fs from "fs"; -import cubes from "./data.json" assert { type: "json" }; +import cubes from "./data.json" with { type: "json" }; const envs = ["test", "int", "prod"]; const queries = [ @@ -21,8 +21,7 @@ const generateAutoTests = () => { env, query, cube, - `https://${ - env === "prod" ? "" : `${env}.` + `https://${env === "prod" ? "" : `${env}.` }visualize.admin.ch/api/graphql`, true, false @@ -45,21 +44,21 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Download, unzip and install k6 binary run: | - wget https://github.com/grafana/k6/releases/download/v0.49.0/k6-v0.49.0-linux-amd64.tar.gz - tar -xzf k6-v0.49.0-linux-amd64.tar.gz - sudo cp k6-v0.49.0-linux-amd64/k6 /usr/local/bin/k6 - export PATH=$PATH:/usr/local/bin + wget https://github.com/grafana/k6/releases/download/v0.49.0/k6-v0.49.0-linux-amd64.tar.gz + tar -xzf k6-v0.49.0-linux-amd64.tar.gz + sudo cp k6-v0.49.0-linux-amd64/k6 /usr/local/bin/k6 + export PATH=$PATH:/usr/local/bin ${commands - .map( - (command, i) => ` - name: Run k6 test (iteration ${i + 1}) + .map( + (command, i) => ` - name: Run k6 test (iteration ${i + 1}) run: ${command}` - ) - .join("\n")}`; + ) + .join("\n")}`; - fs.writeFileSync("./.github/workflows/performance-tests.yml", file); + fs.writeFileSync("./.github/workflows/performance-tests.yaml", file); }; generateAutoTests(); @@ -81,10 +80,11 @@ const generatePRTests = () => { name: GraphQL performance tests (PR) -on: [deployment_status] +on: + - deployment_status env: - SUMMARY: '' + SUMMARY: "" jobs: run_tests: @@ -93,22 +93,22 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Send an HTTP request to start up the server run: | curl -s '\${{ github.event.deployment_status.target_url }}/api/graphql' -X 'POST' -H 'Content-Type: application/json' -d '{"operationName":"DataCubeObservations","variables":{"locale":"en","sourceType":"sparql","sourceUrl":"https://lindas.admin.ch/query","cubeFilter":{"iri":"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9","filters":{"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/Kanton":{"type":"single","value":"https://ld.admin.ch/canton/1"}}}},"query":"query DataCubeObservations($sourceType: String!, $sourceUrl: DataSourceUrl!, $locale: String!, $cubeFilter: DataCubeObservationFilter!) { dataCubeObservations(sourceType: $sourceType, sourceUrl: $sourceUrl, locale: $locale, cubeFilter: $cubeFilter) }"}' > /dev/null - name: Download, unzip and install k6 binary run: | - wget https://github.com/grafana/k6/releases/download/v0.49.0/k6-v0.49.0-linux-amd64.tar.gz - tar -xzf k6-v0.49.0-linux-amd64.tar.gz - sudo cp k6-v0.49.0-linux-amd64/k6 /usr/local/bin/k6 - export PATH=$PATH:/usr/local/bin + wget https://github.com/grafana/k6/releases/download/v0.49.0/k6-v0.49.0-linux-amd64.tar.gz + tar -xzf k6-v0.49.0-linux-amd64.tar.gz + sudo cp k6-v0.49.0-linux-amd64/k6 /usr/local/bin/k6 + export PATH=$PATH:/usr/local/bin ${commands - .map( - (command, i) => ` - name: Run k6 test (iteration ${i + 1}) + .map( + (command, i) => ` - name: Run k6 test (iteration ${i + 1}) run: echo "SUMMARY=\${{ env.SUMMARY }}$(${command})" >> $GITHUB_ENV` - ) - .join("\n")} + ) + .join("\n")} - name: GQL performance tests ❌ if: \${{ env.SUMMARY != '' }} run: | @@ -123,12 +123,12 @@ ${commands }' `; - fs.writeFileSync("./.github/workflows/performance-tests-pr.yml", file); + fs.writeFileSync("./.github/workflows/performance-tests-pr.yaml", file); }; generatePRTests(); -function getRunCommand( +function getRunCommand ( env, query, cube, @@ -136,11 +136,8 @@ function getRunCommand( sendToPrometheus = true, checkTiming = true ) { - return `k6 run${ - sendToPrometheus ? " -o experimental-prometheus-rw" : "" - } --tag testid=${query} --env ENV=${env} --env ENDPOINT=${endpoint} --env CUBE_IRI=${ - cube.iri - } --env CUBE_LABEL=${cube.label} --env CHECK_TIMING=${ - checkTiming ? "true" : "false" - } --env WORKSPACE=\${{ github.workspace }} --quiet -