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
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: Validate

on:
push:
branches: [main]
branches:
- main
pull_request:
branches: [main]
branches:
- main

jobs:
base-checks:
Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/e2e.yml → .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: E2E

on: [deployment_status]
on:
- deployment_status

jobs:
e2e:
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

name: GraphQL performance tests (PR)

on: [deployment_status]
on:
- deployment_status

env:
SUMMARY: ''
SUMMARY: ""

jobs:
run_tests:
Expand All @@ -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 - <k6/performance-tests/graphql/DataCubeComponents.js)" >> $GITHUB_ENV
- name: Run k6 test (iteration 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 - <k6/performance-tests/graphql/DataCubeComponents.js
- name: Run k6 test (iteration 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
preload-varnish-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22.x
node-version: "lts/*"
cache: "yarn"
cache-dependency-path: "**/yarn.lock"
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Public documentation is available at https://visualize.admin.ch/docs/.
## 2. <a name='DevelopmentEnvironment'></a>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
Expand Down
File renamed without changes.
File renamed without changes.
63 changes: 30 additions & 33 deletions k6/performance-tests/generate-github-actions.mjs
Original file line number Diff line number Diff line change
@@ -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 = [
Expand All @@ -21,8 +21,7 @@ const generateAutoTests = () => {
env,
query,
cube,
`https://${
env === "prod" ? "" : `${env}.`
`https://${env === "prod" ? "" : `${env}.`
}visualize.admin.ch/api/graphql`,
true,
false
Expand All @@ -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();
Expand All @@ -81,10 +80,11 @@ const generatePRTests = () => {

name: GraphQL performance tests (PR)

on: [deployment_status]
on:
- deployment_status

env:
SUMMARY: ''
SUMMARY: ""

jobs:
run_tests:
Expand All @@ -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: |
Expand All @@ -123,24 +123,21 @@ ${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,
endpoint,
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 - <k6/performance-tests/graphql/${query}.js`;
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 - <k6/performance-tests/graphql/${query}.js`;
}
Loading