feat(database monitor): handles multi-region and connection pooling #311
Workflow file for this run
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
name: Preview service acceptance test | |
on: | |
workflow_dispatch: | |
pull_request: # Pushing a new commit to the HEAD ref of a pull request will trigger the “synchronize” event | |
paths: | |
- .yarnrc.yml . | |
- .yarn | |
- package.json | |
- '.github/workflows/preview-service-acceptance.yml' | |
- 'packages/frontend-2/type-augmentations/stubs/**/*' | |
- 'packages/preview-service/**/*' | |
- 'packages/viewer/**/*' | |
- 'packages/objectloader/**/*' | |
- 'packages/shared/**/*' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository_owner }}/speckle-preview-service | |
OUTPUT_FILE_PATH: 'preview-service-output/${{ github.sha }}.png' | |
jobs: | |
build-preview-service: | |
name: Build Preview Service | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: read | |
packages: write # publishing container to GitHub registry | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to the Container registry | |
uses: docker/[email protected] | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/[email protected] | |
with: | |
tags: type=sha,format=long | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and load preview-service Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./packages/preview-service/Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
outputs: | |
tags: ${{ steps.meta.outputs.tags }} | |
preview-service-acceptance: | |
name: Preview Service Acceptance test | |
runs-on: ubuntu-latest | |
needs: build-preview-service | |
permissions: | |
contents: write # to update the screenshot saved in the branch. This is a HACK as GitHub API does not yet support uploading attachments to a comment. | |
pull-requests: write # to write a comment on the PR | |
packages: read # to download the preview-service image | |
services: | |
postgres: | |
# Docker Hub image | |
image: postgres:16.4-bookworm@sha256:91f464e7ba0ad91a106c94cff079fb4384139291b8c0502fd36989cf2c788bbb | |
env: | |
POSTGRES_DB: preview_service_test | |
POSTGRES_PASSWORD: preview_service_test | |
POSTGRES_USER: preview_service_test | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
preview-service: | |
image: ${{ needs.build-preview-service.outputs.tags }} | |
env: | |
# note that the host is the postgres service name | |
PG_CONNECTION_STRING: postgres://preview_service_test:preview_service_test@postgres:5432/preview_service_test | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'yarn' | |
- name: Install dependencies | |
working-directory: packages/preview-service | |
run: yarn install | |
- name: Run the acceptance test | |
working-directory: packages/preview-service | |
run: yarn test:acceptance | |
env: | |
NODE_ENV: test | |
TEST_DB: preview_service_test | |
# note that the host is localhost, but the port is the port mapped to the postgres service | |
PG_CONNECTION_STRING: postgres://preview_service_test:preview_service_test@localhost:5432/preview_service_test | |
OUTPUT_FILE_PATH: ${{ env.OUTPUT_FILE_PATH }} | |
S3_BUCKET: ${{ vars.S3_BUCKET }} | |
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} | |
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }} | |
S3_ENDPOINT: ${{ vars.S3_ENDPOINT }} | |
S3_REGION: ${{ vars.S3_REGION }} | |
- uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '📸 Preview service has generated <a href="${{ vars.S3_ENDPOINT }}/${{ vars.S3_BUCKET }}/${{ env.OUTPUT_FILE_PATH}}">an image.</a>' | |
}) |