From 295f02af6bad05f157b2a442903926ab803c8811 Mon Sep 17 00:00:00 2001 From: Daniel Gak Anagrov Date: Mon, 9 Jun 2025 10:27:19 +0200 Subject: [PATCH] feat(ci): gha and blacksmith for prs (#4647) --- .circleci/config.yml | 100 +-- .github/workflows/builds.yml | 97 +++ .github/workflows/ci.yml | 37 ++ .../workflows/config/multiregion.test-ci.json | 46 ++ .github/workflows/scripts/common.sh | 20 + .github/workflows/scripts/get_version.sh | 26 + .github/workflows/tests.yml | 567 ++++++++++++++++++ 7 files changed, 845 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/builds.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/config/multiregion.test-ci.json create mode 100644 .github/workflows/scripts/common.sh create mode 100755 .github/workflows/scripts/get_version.sh create mode 100644 .github/workflows/tests.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index a961cca4c..5ac3e25ae 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,6 +22,18 @@ aliases: name: Install Dependencies command: YARN_ENABLE_HARDENED_MODE=0 PUPPETEER_SKIP_DOWNLOAD=true PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn + - &filters-allow-all + tags: + # run tests for any commit on any branch, including any tags + only: /.*/ + + - &filters-only-main-hotfix-testing + branches: + only: &branches-special + - main + - /^hotfix.*$/ + - /^testing\d*$/ + workflows: test-build: jobs: @@ -39,51 +51,52 @@ workflows: - speckle-server-licensing - stripe-integration - speckle-server-codecov - filters: &filters-allow-all - tags: - # run tests for any commit on any branch, including any tags - only: /.*/ + filters: *filters-only-main-hotfix-testing requires: - docker-build-postgres-container - test-server-no-ff: + filters: *filters-only-main-hotfix-testing + requires: + - docker-build-postgres-container + + - test-server-multiregion: + context: + - speckle-server-licensing + - stripe-integration + - speckle-server-codecov filters: *filters-allow-all requires: - docker-build-postgres-container - - test-server-multiregion: *test-server-job-definition - - test-frontend-2: - filters: *filters-allow-all + filters: *filters-only-main-hotfix-testing - test-viewer: - filters: *filters-allow-all + filters: *filters-only-main-hotfix-testing - test-objectsender: - filters: *filters-allow-all + filters: *filters-only-main-hotfix-testing - test-shared: - filters: *filters-allow-all + filters: *filters-only-main-hotfix-testing - test-preview-service: - filters: *filters-allow-all + filters: *filters-only-main-hotfix-testing - test-ui-components: - filters: *filters-allow-all + filters: *filters-only-main-hotfix-testing - ui-components-chromatic: context: - chromatic-ui-components - filters: *filters-allow-all + filters: *filters-only-main-hotfix-testing - deployment-testing-approval: type: approval filters: &filters-ignore-main-branch-or-all-tags branches: - ignore: &branches-special - - main - - /^hotfix.*$/ - - /^testing\d*$/ + ignore: *branches-special tags: ignore: /.*/ @@ -107,10 +120,7 @@ workflows: # - docker-build-docker-compose-ingress - deployment-test-helm-chart: - filters: &filters-deployment-testing - tags: - # run tests for any commit on any branch, including any tags - only: /.*/ + filters: *filters-only-main-hotfix-testing requires: - get-version - deployment-testing-approval @@ -126,66 +136,64 @@ workflows: filters: *filters-allow-all - pre-commit: - filters: *filters-allow-all + filters: *filters-only-main-hotfix-testing - lint-and-prettier: - filters: *filters-allow-all + filters: *filters-only-main-hotfix-testing - docker-build-server: context: &build-context - github-readonly-public-repos - docker-hub - filters: &filters-build - tags: - only: /.*/ + filters: *filters-only-main-hotfix-testing requires: - get-version - docker-build-frontend-2: context: *build-context - filters: *filters-build + filters: *filters-only-main-hotfix-testing requires: - get-version - docker-build-webhooks: context: *build-context - filters: *filters-build + filters: *filters-only-main-hotfix-testing requires: - get-version - docker-build-file-imports: context: *build-context - filters: *filters-build + filters: *filters-only-main-hotfix-testing requires: - get-version - docker-build-previews: context: *build-context - filters: *filters-build + filters: *filters-only-main-hotfix-testing requires: - get-version - docker-build-test-container: context: *build-context - filters: *filters-build + filters: *filters-only-main-hotfix-testing requires: - get-version - docker-build-postgres-container: context: *build-context - filters: *filters-build + filters: *filters-allow-all requires: - get-version - docker-build-monitor-container: context: *build-context - filters: *filters-build + filters: *filters-only-main-hotfix-testing requires: - get-version - docker-build-docker-compose-ingress: context: *build-context - filters: *filters-build + filters: *filters-only-main-hotfix-testing requires: - get-version @@ -196,11 +204,7 @@ workflows: - docker-publish-server: context: &docker-hub-context - docker-hub - filters: &filters-publish - branches: - ignore: /pull\/[0-9]+/ - tags: - only: /.*/ + filters: *filters-only-main-hotfix-testing requires: - docker-build-server - get-version @@ -218,7 +222,7 @@ workflows: - docker-publish-frontend-2: context: *docker-hub-context - filters: *filters-publish + filters: *filters-only-main-hotfix-testing requires: - docker-build-frontend-2 - get-version @@ -238,14 +242,14 @@ workflows: context: - github-readonly-public-repos - datadog-sourcemaps-publish - filters: *filters-publish + filters: *filters-only-main-hotfix-testing requires: - get-version - publish-approval - docker-publish-webhooks: context: *docker-hub-context - filters: *filters-publish + filters: *filters-only-main-hotfix-testing requires: - docker-build-webhooks - get-version @@ -263,7 +267,7 @@ workflows: - docker-publish-file-imports: context: *docker-hub-context - filters: *filters-publish + filters: *filters-only-main-hotfix-testing requires: - docker-build-file-imports - get-version @@ -281,7 +285,7 @@ workflows: - docker-publish-previews: context: *docker-hub-context - filters: *filters-publish + filters: *filters-only-main-hotfix-testing requires: - docker-build-previews - get-version @@ -299,7 +303,7 @@ workflows: - docker-publish-test-container: context: *docker-hub-context - filters: *filters-publish + filters: *filters-only-main-hotfix-testing requires: - docker-build-test-container - get-version @@ -317,7 +321,7 @@ workflows: - docker-publish-postgres-container: context: *docker-hub-context - filters: *filters-publish + filters: *filters-only-main-hotfix-testing requires: - docker-build-monitor-container - get-version @@ -329,7 +333,7 @@ workflows: - docker-publish-monitor-container: context: *docker-hub-context - filters: *filters-publish + filters: *filters-only-main-hotfix-testing requires: - docker-build-monitor-container - get-version @@ -347,7 +351,7 @@ workflows: - docker-publish-docker-compose-ingress: context: *docker-hub-context - filters: *filters-publish + filters: *filters-only-main-hotfix-testing requires: - docker-build-docker-compose-ingress - get-version diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml new file mode 100644 index 000000000..cf7e683dc --- /dev/null +++ b/.github/workflows/builds.yml @@ -0,0 +1,97 @@ +name: Run all builds + +on: + workflow_call: + inputs: + IMAGE_VERSION_TAG: + required: true + type: string + +jobs: + docker-build-server: + runs-on: blacksmith + name: Server + steps: + - name: Build and push + uses: useblacksmith/build-push-action@v1 + with: + push: false + tags: speckle/speckle-server:${{ inputs.IMAGE_VERSION_TAG }} + file: ./packages/server/Dockerfile + + docker-build-frontend2: + runs-on: blacksmith + name: Frontend2 + steps: + - name: Build and push + uses: useblacksmith/build-push-action@v1 + with: + push: false + tags: speckle/speckle-frontend-2:${{ inputs.IMAGE_VERSION_TAG }} + file: ./packages/frontend-2/Dockerfile + + docker-build-preview-service: + runs-on: blacksmith + name: Preview service + steps: + - name: Build and push + uses: useblacksmith/build-push-action@v1 + with: + push: false + tags: speckle/speckle-preview-service:${{ inputs.IMAGE_VERSION_TAG }} + file: ./packages/preview-service/Dockerfile + + docker-build-webhook-service: + runs-on: blacksmith + name: Webhook service + steps: + - name: Build and push + uses: useblacksmith/build-push-action@v1 + with: + push: false + tags: speckle/speckle-webhook-service:${{ inputs.IMAGE_VERSION_TAG }} + file: ./packages/webhook-service/Dockerfile + + docker-build-fileimport-service: + runs-on: blacksmith + name: File import service + steps: + - name: Build and push + uses: useblacksmith/build-push-action@v1 + with: + push: false + tags: speckle/speckle-fileimport-service:${{ inputs.IMAGE_VERSION_TAG }} + file: ./packages/fileimport-service/Dockerfile + + docker-build-test-deploy: + runs-on: blacksmith + name: Test deploy util + steps: + - name: Build and push + uses: useblacksmith/build-push-action@v1 + with: + push: false + tags: speckle/speckle-test-deployment:${{ inputs.IMAGE_VERSION_TAG }} + file: ./utils/test-deployment/Dockerfile + + docker-build-monitor-deployment: + runs-on: Blacksmith + name: monitor container + steps: + - name: Build and push + uses: useblacksmith/build-push-action@v1 + with: + push: false + tags: speckle/speckle-monitor-deployment:${{ inputs.IMAGE_VERSION_TAG }} + file: ./packages/monitor-deployment/Dockerfile + + docker-build-docker-compose-ingress: + runs-on: blacksmith + name: Docker compose ingress + steps: + - name: Build and push + uses: useblacksmith/build-push-action@v1 + with: + push: false + tags: speckle/speckle-docker-compose-ingress:${{ inputs.IMAGE_VERSION_TAG }} + file: ./utils/docker-compose-ingress/Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..962461dc8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,37 @@ +name: CI Pipeline + +on: pull_request + +jobs: + get-version: + outputs: + IMAGE_VERSION_TAG: ${{ steps.export-step.outputs.IMAGE_VERSION_TAG }} + name: Get version + runs-on: blacksmith + steps: + - uses: actions/checkout@v4.2.2 + - run: git fetch origin 'refs/tags/*:refs/tags/*' + - run: chmod +x ./get_version.sh ./common.sh + working-directory: ./.github/workflows/scripts + - run: ./get_version.sh >> result + working-directory: ./.github/workflows/scripts + - run: echo "IMAGE_VERSION_TAG=$(cat result)" + working-directory: ./.github/workflows/scripts + - id: export-step + run: echo "IMAGE_VERSION_TAG=$(cat result)" >> "$GITHUB_OUTPUT" + working-directory: ./.github/workflows/scripts + + tests: + needs: get-version + uses: ./.github/workflows/tests.yml + with: + IMAGE_VERSION_TAG: ${{ needs.get-version.outputs.IMAGE_VERSION_TAG }} + DOCKERHUB_USERNAME: 'speckledevops' + secrets: inherit + + builds: + needs: get-version + uses: ./.github/workflows/builds.yml + with: + IMAGE_VERSION_TAG: ${{ needs.get-version.outputs.IMAGE_VERSION_TAG }} + secrets: inherit diff --git a/.github/workflows/config/multiregion.test-ci.json b/.github/workflows/config/multiregion.test-ci.json new file mode 100644 index 000000000..477214a58 --- /dev/null +++ b/.github/workflows/config/multiregion.test-ci.json @@ -0,0 +1,46 @@ +{ + "main": { + "postgres": { + "connectionUri": "postgres://speckle:speckle@localhost:5432/speckle2_test", + "privateConnectionUri": "postgres://speckle:speckle@postgres0:5432/speckle2_test" + }, + "blobStorage": { + "accessKey": "minioadmin", + "secretKey": "minioadmin", + "bucket": "speckle-server", + "createBucketIfNotExists": true, + "endpoint": "http://localhost:9000", + "s3Region": "us-east-1" + } + }, + "regions": { + "region1": { + "postgres": { + "connectionUri": "postgres://speckle:speckle@localhost:5433/speckle2_test", + "privateConnectionUri": "postgres://speckle:speckle@postgres1:5433/speckle2_test" + }, + "blobStorage": { + "accessKey": "minioadmin", + "secretKey": "minioadmin", + "bucket": "speckle-server", + "createBucketIfNotExists": true, + "endpoint": "http://localhost:9001", + "s3Region": "us-east-1" + } + }, + "region2": { + "postgres": { + "connectionUri": "postgres://speckle:speckle@localhost:5434/speckle2_test", + "privateConnectionUri": "postgres://speckle:speckle@postgres2:5434/speckle2_test" + }, + "blobStorage": { + "accessKey": "minioadmin", + "secretKey": "minioadmin", + "bucket": "speckle-server", + "createBucketIfNotExists": true, + "endpoint": "http://localhost:9002", + "s3Region": "us-east-1" + } + } + } +} diff --git a/.github/workflows/scripts/common.sh b/.github/workflows/scripts/common.sh new file mode 100644 index 000000000..ec0e55a69 --- /dev/null +++ b/.github/workflows/scripts/common.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -eo pipefail + +# shellcheck disable=SC2034 +DOCKER_IMAGE_TAG="speckle/speckle-${SPECKLE_SERVER_PACKAGE}" + +# shellcheck disable=SC2034,SC2086 +IMAGE_VERSION_TAG="${IMAGE_VERSION_TAG:-${GITHUB_SHA}}" + +# shellcheck disable=SC2068,SC2046 +LAST_RELEASE="$(git describe --always --tags $(git rev-list --tags) | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)" # get the last release tag. FIXME: Fails if a commit is tagged with more than one tag: https://stackoverflow.com/questions/8089002/git-describe-with-two-tags-on-the-same-commit/56039163#56039163 + +# shellcheck disable=SC2034 +NEXT_RELEASE="$(echo "${LAST_RELEASE}" | awk -F. -v OFS=. '{$NF += 1 ; print}')" + +# shellcheck disable=SC2034 +BRANCH_NAME_TRUNCATED="$(echo "${GITHUB_HEAD_REF}" | cut -c -50 | sed 's/[^a-zA-Z0-9.-]/-/g')" # docker has a 128 character tag limit, so ensuring the branch name will be short enough + +# shellcheck disable=SC2034 +COMMIT_SHA1_TRUNCATED="$(echo "${GITHUB_SHA}" | cut -c -7)" diff --git a/.github/workflows/scripts/get_version.sh b/.github/workflows/scripts/get_version.sh new file mode 100755 index 000000000..61b654bba --- /dev/null +++ b/.github/workflows/scripts/get_version.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -eo pipefail + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +# shellcheck disable=SC1090,SC1091 +source "${SCRIPT_DIR}/common.sh" + + +if [[ "${GITHUB_REF}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "${GITHUB_REF}" + exit 0 +fi + +if [[ "${GITHUB_HEAD_REF}" == "main" ]]; then + echo "${NEXT_RELEASE}-alpha.${GITHUB_RUN_ID}" + exit 0 +fi + +# if branch name truncated contains an underscore, we should exit +if [[ "${BRANCH_NAME_TRUNCATED}" =~ "_" ]]; then + echo "Branch name contains an underscore, exiting" + exit 1 +fi + +echo "${NEXT_RELEASE}-branch.${BRANCH_NAME_TRUNCATED}.${GITHUB_RUN_ID}-${COMMIT_SHA1_TRUNCATED}" +exit 0 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..f5c8d1399 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,567 @@ +name: Run all tests + +on: + workflow_call: + inputs: + IMAGE_VERSION_TAG: + required: true + type: string + DOCKERHUB_USERNAME: + required: true + type: string + secrets: + LICENSE_TOKEN: + required: true + CHROMATIC_PROJECT_TOKEN: + required: true + STRIPE_API_KEY: + required: true + # STRIPE_ENDPOINT_SIGNING_KEY: + # required: true + APOLLO_KEY: + required: true + CODECOV_TOKEN: + required: true + DOCKERHUB_TOKEN: + required: true + +jobs: + lint-and-prettier: + name: Lint and prettier + runs-on: blacksmith + steps: + - uses: actions/checkout@v4.2.2 + - uses: useblacksmith/setup-node@v5 + with: + node-version: 22 + cache: yarn + - name: Install hardened (no HARD flag) + run: PUPPETEER_SKIP_DOWNLOAD=true PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn --immutable + - name: Build public packages + run: yarn build:public + - name: Lint everything + run: yarn eslint:projectwide + - name: Run prettier check + run: yarn prettier:check + - name: Check JSON Schema is up to date + run: | + yarn helm:jsonschema:generate + git diff --exit-code + + pre-commit: + name: Precommit check + runs-on: blacksmith + container: + image: speckle/pre-commit-runner:latest + steps: + - uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + - run: git config --global --add safe.directory $PWD + - name: Set precommit + run: pre-commit install-hooks --config ./.pre-commit-config.yaml + - name: Run precommit + run: pre-commit run --all-files --config ./.pre-commit-config.yaml + - name: Diff on failure + if: failure() + run: git --no-pager diff + + test-frontend-2: + name: Frontend + runs-on: blacksmith + steps: + - uses: actions/checkout@v4.2.2 + - uses: useblacksmith/setup-node@v5 + with: + node-version: 22 + cache: yarn + - name: Install dependencies + run: YARN_ENABLE_HARDENED_MODE=0 PUPPETEER_SKIP_DOWNLOAD=true PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn --immutable + - name: Build public packages + run: yarn build:public + - name: Lint everything + run: yarn lint:ci + working-directory: 'packages/frontend-2' + + test-viewer: + name: Viwer + runs-on: blacksmith + steps: + - uses: actions/checkout@v4.2.2 + - uses: useblacksmith/setup-node@v5 + with: + node-version: 22 + cache: yarn + - name: Install dependencies + run: YARN_ENABLE_HARDENED_MODE=0 PUPPETEER_SKIP_DOWNLOAD=true PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn --immutable + - name: Build public packages + run: yarn build:public + - name: Lint viewer + run: yarn lint:ci + working-directory: 'packages/viewer' + - name: Run tests + run: yarn test + working-directory: 'packages/viewer' + - name: Lint viewer-sandbox + run: yarn lint:ci + working-directory: 'packages/viewer-sandbox' + - name: Build viewer-sandbox + run: yarn build + working-directory: 'packages/viewer-sandbox' + + ui-components-chromatic: + env: + CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} + name: UI components chromatic + runs-on: blacksmith + steps: + - uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + - uses: useblacksmith/setup-node@v5 + with: + node-version: 22 + cache: yarn + - name: Install dependencies + run: YARN_ENABLE_HARDENED_MODE=0 PUPPETEER_SKIP_DOWNLOAD=true PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn --immutable + - name: Build public packages + run: yarn build:public + - name: Run chromatic + run: yarn chromatic + working-directory: 'packages/ui-components' + + test-shared: + name: Shared + runs-on: blacksmith + steps: + - uses: actions/checkout@v4.2.2 + - uses: useblacksmith/setup-node@v5 + with: + node-version: 22 + cache: yarn + - name: Install dependencies + run: YARN_ENABLE_HARDENED_MODE=0 PUPPETEER_SKIP_DOWNLOAD=true PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn --immutable + - name: Lint + run: yarn lint:ci + working-directory: 'packages/shared' + - name: Run tests (all FFs) + run: ENABLE_ALL_FFS=1 yarn test:ci + working-directory: 'packages/shared' + - name: Run tests (no FFs) + run: DISABLE_ALL_FFS=1 yarn test:ci + working-directory: 'packages/shared' + - uses: codecov/codecov-action@v5 + with: + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + files: packages/shared/coverage/coverage-final.json + - name: Build + run: yarn build + working-directory: 'packages/shared' + - name: Ensure ESM import works + run: node ./e2e/testEsm.mjs + working-directory: 'packages/shared' + - name: Ensure CJS require works + run: node ./e2e/testCjs.cjs + working-directory: 'packages/shared' + + test-objectsender: + name: Object Sender + runs-on: blacksmith + steps: + - uses: actions/checkout@v4.2.2 + - uses: useblacksmith/setup-node@v5 + with: + node-version: 22 + cache: yarn + - name: Install dependencies + run: YARN_ENABLE_HARDENED_MODE=0 PUPPETEER_SKIP_DOWNLOAD=true PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn --immutable + - name: Build public packages + run: yarn build:public + - name: Lint everything + run: yarn test:ci + working-directory: 'packages/objectsender' + - uses: codecov/codecov-action@v5 + with: + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + files: packages/objectsender/coverage/coverage-final.json + + test-ui-components: + name: UI Components + runs-on: blacksmith + steps: + - uses: actions/checkout@v4.2.2 + - uses: useblacksmith/setup-node@v5 + with: + node-version: 22 + cache: yarn + - name: Install dependencies + run: YARN_ENABLE_HARDENED_MODE=0 PUPPETEER_SKIP_DOWNLOAD=true yarn --immutable # we need PLAYWRIGHT + - name: Build public packages + run: yarn build:public + - name: Lint tailwind theme + run: yarn lint:ci + working-directory: 'packages/tailwind-theme' + - name: Lint ui components + run: yarn lint:ci + working-directory: 'packages/ui-components' + - name: Lint component nuxt package + run: yarn lint:ci + working-directory: 'packages/ui-components-nuxt' + - name: Test via Storybook + run: yarn storybook:test:ci + working-directory: 'packages/ui-components' + + test-preview-service: + name: Preview service + runs-on: blacksmith + steps: + - uses: actions/checkout@v4.2.2 + - uses: useblacksmith/setup-node@v5 + with: + node-version: 22 + cache: yarn + - name: Install dependencies + run: YARN_ENABLE_HARDENED_MODE=0 PUPPETEER_SKIP_DOWNLOAD=true PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn --immutable + - name: Build public packages + run: yarn build:public + - name: Lint everything + run: yarn lint:ci + working-directory: 'packages/preview-service' + + docker-build-postgres-container: + runs-on: blacksmith + name: Docker build postgres container + steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ inputs.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: useblacksmith/build-push-action@v1 + with: + push: true + tags: speckle/speckle-postgres:${{ inputs.IMAGE_VERSION_TAG }} + file: ./utils/postgres/Dockerfile + + test-server: + name: Server + needs: [docker-build-postgres-container] + runs-on: blacksmith-8vcpu-ubuntu-2404 + services: + redis: + image: redis:7.2.4 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 6379:6379 + postgres: + image: speckle/speckle-postgres:${{ inputs.IMAGE_VERSION_TAG }} + env: + POSTGRES_DB: speckle2_test + POSTGRES_PASSWORD: speckle + POSTGRES_USER: speckle + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + minio: + image: bitnami/minio + env: + MINIO_ROOT_USER: minioadmin + MINIO_ROOT_PASSWORD: minioadmin + MINIO_SKIP_CLIENT: yes + ports: + - 9000:9000 + env: + NODE_ENV: test + POSTGRES_URL: 'postgres://speckle:speckle@localhost:5432/speckle2_test' + POSTGRES_MAX_CONNECTIONS_SERVER: 20 + SESSION_SECRET: 'keyboard cat' + STRATEGY_LOCAL: 'true' + CANONICAL_URL: 'http://127.0.0.1:3000' + S3_ENDPOINT: 'http://localhost:9000' + S3_ACCESS_KEY: 'minioadmin' + S3_SECRET_KEY: 'minioadmin' + S3_BUCKET: 'speckle-server' + S3_CREATE_BUCKET: 'true' + REDIS_URL: 'redis://localhost:6379' + S3_REGION: '' # optional, defaults to 'us-east-1' + FRONTEND_ORIGIN: 'http://127.0.0.1:8081' + ENCRYPTION_KEYS_PATH: 'test/assets/automate/encryptionKeys.json' + ENABLE_ALL_FFS: 'true' + RATELIMITER_ENABLED: 'false' + LICENSE_TOKEN: ${{ secrets.LICENSE_TOKEN }} + CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + STRIPE_API_KEY: ${{ secrets.STRIPE_API_KEY }} + STRIPE_ENDPOINT_SIGNING_KEY: ${{ secrets.STRIPE_ENDPOINT_SIGNING_KEY }} + APOLLO_KEY: ${{ secrets.APOLLO_KEY }} + steps: + - uses: actions/checkout@v4.2.2 + - uses: useblacksmith/setup-node@v5 + with: + node-version: 22 + cache: yarn + - name: Install dependencies + run: YARN_ENABLE_HARDENED_MODE=0 PUPPETEER_SKIP_DOWNLOAD=true PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn --immutable + - name: Build public packages + run: yarn build:public + - run: cp .env.test-example .env.test + working-directory: 'packages/server' + - name: 'Lint' + run: yarn lint:ci + working-directory: 'packages/server' + - name: 'Run test' + run: yarn test:report + working-directory: 'packages/server' + timeout-minutes: 30 + - uses: codecov/codecov-action@v5 + with: + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + files: packages/server/coverage/lcov.info + - name: Introspect GQL schema for subsequent checks + run: 'IGNORE_MISSING_MIRATIONS=true yarn cli graphql introspect' + working-directory: 'packages/server' + - name: Checking for GQL schema breakages against app.speckle.systems + run: 'yarn rover graph check Speckle-Server@app-speckle-systems --schema ./introspected-schema.graphql' + working-directory: 'packages/server' + - name: Checking for GQL schema breakages against latest.speckle.systems + run: 'yarn rover graph check Speckle-Server@latest-speckle-systems --schema ./introspected-schema.graphql' + working-directory: 'packages/server' + + test-server-no-ff: + name: Server no ff + needs: [docker-build-postgres-container] + runs-on: blacksmith-8vcpu-ubuntu-2404 + services: + redis: + image: redis:7.2.4 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 6379:6379 + postgres: + image: speckle/speckle-postgres:${{ inputs.IMAGE_VERSION_TAG }} + env: + POSTGRES_DB: speckle2_test + POSTGRES_PASSWORD: speckle + POSTGRES_USER: speckle + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + minio: + image: bitnami/minio + env: + MINIO_ROOT_USER: minioadmin + MINIO_ROOT_PASSWORD: minioadmin + MINIO_SKIP_CLIENT: yes + ports: + - 9000:9000 + env: + DISABLE_ALL_FFS: 'true' + NODE_ENV: test + POSTGRES_URL: 'postgres://speckle:speckle@localhost:5432/speckle2_test' + POSTGRES_MAX_CONNECTIONS_SERVER: 20 + SESSION_SECRET: 'keyboard cat' + STRATEGY_LOCAL: 'true' + CANONICAL_URL: 'http://127.0.0.1:3000' + S3_ENDPOINT: 'http://localhost:9000' + S3_ACCESS_KEY: 'minioadmin' + S3_SECRET_KEY: 'minioadmin' + S3_BUCKET: 'speckle-server' + S3_CREATE_BUCKET: 'true' + REDIS_URL: 'redis://localhost:6379' + S3_REGION: '' # optional, defaults to 'us-east-1' + FRONTEND_ORIGIN: 'http://127.0.0.1:8081' + ENCRYPTION_KEYS_PATH: 'test/assets/automate/encryptionKeys.json' + ENABLE_ALL_FFS: 'true' + RATELIMITER_ENABLED: 'false' + LICENSE_TOKEN: ${{ secrets.LICENSE_TOKEN }} + CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + STRIPE_API_KEY: ${{ secrets.STRIPE_API_KEY }} + STRIPE_ENDPOINT_SIGNING_KEY: ${{ secrets.STRIPE_ENDPOINT_SIGNING_KEY }} + APOLLO_KEY: ${{ secrets.APOLLO_KEY }} + + steps: + - uses: actions/checkout@v4.2.2 + - uses: useblacksmith/setup-node@v5 + with: + node-version: 22 + cache: yarn + - name: Install dependencies + run: YARN_ENABLE_HARDENED_MODE=0 PUPPETEER_SKIP_DOWNLOAD=true PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn --immutable + - name: Build public packages + run: yarn build:public + - run: cp .env.test-example .env.test + working-directory: 'packages/server' + - name: 'Run test' + run: yarn test:report + working-directory: 'packages/server' + timeout-minutes: 30 + - uses: codecov/codecov-action@v5 + with: + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + files: packages/server/coverage/lcov.info + + test-server-multiregion: + name: Server multiregion + needs: [docker-build-postgres-container] + if: false # disabled + runs-on: blacksmith + services: + redis: + image: redis:7.2.4 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 6379:6379 + + postgres0: + image: speckle/speckle-postgres:${{ inputs.IMAGE_VERSION_TAG }} + env: + POSTGRES_DB: speckle2_test + POSTGRES_PASSWORD: speckle + POSTGRES_USER: speckle + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + postgres1: + image: speckle/speckle-postgres:${{ inputs.IMAGE_VERSION_TAG }} + env: + POSTGRES_DB: speckle2_test + POSTGRES_PASSWORD: speckle + POSTGRES_USER: speckle + ports: + - 5433:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + postgres2: + image: speckle/speckle-postgres:${{ inputs.IMAGE_VERSION_TAG }} + env: + POSTGRES_DB: speckle2_test + POSTGRES_PASSWORD: speckle + POSTGRES_USER: speckle + ports: + - 5434:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + minio0: + image: bitnami/minio + env: + MINIO_ROOT_USER: minioadmin + MINIO_ROOT_PASSWORD: minioadmin + MINIO_SKIP_CLIENT: yes + ports: + - 9000:9000 + + minio1: + image: bitnami/minio + env: + MINIO_ROOT_USER: minioadmin + MINIO_ROOT_PASSWORD: minioadmin + MINIO_SKIP_CLIENT: yes + ports: + - 9001:9000 + + minio2: + image: bitnami/minio + env: + MINIO_ROOT_USER: minioadmin + MINIO_ROOT_PASSWORD: minioadmin + MINIO_SKIP_CLIENT: yes + ports: + - 9002:9000 + + env: + NODE_ENV: test + POSTGRES_URL: 'postgres://speckle:speckle@localhost:5432/speckle2_test' + POSTGRES_MAX_CONNECTIONS_SERVER: 50 + SESSION_SECRET: 'keyboard cat' + STRATEGY_LOCAL: 'true' + CANONICAL_URL: 'http://127.0.0.1:3000' + S3_ENDPOINT: 'http://localhost:9000' + S3_ACCESS_KEY: 'minioadmin' + S3_SECRET_KEY: 'minioadmin' + S3_BUCKET: 'speckle-server' + S3_CREATE_BUCKET: 'true' + REDIS_URL: 'redis://localhost:6379' + S3_REGION: '' # optional, defaults to 'us-east-1' + FRONTEND_ORIGIN: 'http://127.0.0.1:8081' + ENCRYPTION_KEYS_PATH: 'test/assets/automate/encryptionKeys.json' + ENABLE_ALL_FFS: 'true' + RATELIMITER_ENABLED: 'false' + LICENSE_TOKEN: ${{ secrets.LICENSE_TOKEN }} + CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + STRIPE_API_KEY: ${{ secrets.STRIPE_API_KEY }} + STRIPE_ENDPOINT_SIGNING_KEY: ${{ secrets.STRIPE_ENDPOINT_SIGNING_KEY }} + # + # This are the only different keys: + # + MULTI_REGION_CONFIG_PATH: '../../.github/workflows/config/multiregion.test-ci.json' + FF_GATEKEEPER_MODULE_ENABLED: 'true' + FF_WORKSPACES_MODULE_ENABLED: 'true' + FF_WORKSPACES_MULTI_REGION_ENABLED: 'true' + FF_MOVE_PROJECT_REGION_ENABLED: 'true' + RUN_TESTS_IN_MULTIREGION_MODE: true + steps: + - uses: actions/checkout@v4.2.2 + - uses: useblacksmith/setup-node@v5 + with: + node-version: 22 + cache: yarn + - name: Install dependencies + run: YARN_ENABLE_HARDENED_MODE=0 PUPPETEER_SKIP_DOWNLOAD=true PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn --immutable + - name: Build public packages + run: yarn build:public + - run: cp .env.test-example .env.test + working-directory: 'packages/server' + - name: 'Run test' + run: yarn test:report + working-directory: 'packages/server' + timeout-minutes: 30 + - uses: codecov/codecov-action@v5 + with: + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + files: packages/server/coverage/lcov.info