-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(preview-service): conforms to design patterns, adds tests, a…
…nd is typed (#2429) Co-authored-by: Kristaps Fabians Geikins <[email protected]>
- Loading branch information
1 parent
f8878b4
commit 9a28e46
Showing
83 changed files
with
2,774 additions
and
956 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,9 @@ workflows: | |
- test-objectsender: | ||
filters: *filters-allow-all | ||
|
||
- test-preview-service: | ||
filters: *filters-allow-all | ||
|
||
- test-ui-components: | ||
filters: *filters-allow-all | ||
|
||
|
@@ -176,6 +179,7 @@ workflows: | |
- test-objectsender | ||
- test-server | ||
- test-server-no-ff | ||
- test-preview-service | ||
|
||
- docker-publish-frontend: | ||
context: *docker-hub-context | ||
|
@@ -190,6 +194,7 @@ workflows: | |
- test-objectsender | ||
- test-server | ||
- test-server-no-ff | ||
- test-preview-service | ||
|
||
- docker-publish-frontend-2: | ||
context: *docker-hub-context | ||
|
@@ -204,6 +209,7 @@ workflows: | |
- test-objectsender | ||
- test-server | ||
- test-server-no-ff | ||
- test-preview-service | ||
|
||
- docker-publish-webhooks: | ||
context: *docker-hub-context | ||
|
@@ -218,6 +224,7 @@ workflows: | |
- test-objectsender | ||
- test-server | ||
- test-server-no-ff | ||
- test-preview-service | ||
|
||
- docker-publish-file-imports: | ||
context: *docker-hub-context | ||
|
@@ -232,6 +239,7 @@ workflows: | |
- test-objectsender | ||
- test-server | ||
- test-server-no-ff | ||
- test-preview-service | ||
|
||
- docker-publish-previews: | ||
context: *docker-hub-context | ||
|
@@ -246,6 +254,7 @@ workflows: | |
- test-objectsender | ||
- test-server | ||
- test-server-no-ff | ||
- test-preview-service | ||
|
||
- docker-publish-test-container: | ||
context: *docker-hub-context | ||
|
@@ -260,6 +269,7 @@ workflows: | |
- test-objectsender | ||
- test-server | ||
- test-server-no-ff | ||
- test-preview-service | ||
|
||
- docker-publish-monitor-container: | ||
context: *docker-hub-context | ||
|
@@ -274,6 +284,7 @@ workflows: | |
- test-objectsender | ||
- test-server | ||
- test-server-no-ff | ||
- test-preview-service | ||
|
||
- docker-publish-docker-compose-ingress: | ||
context: *docker-hub-context | ||
|
@@ -288,6 +299,7 @@ workflows: | |
- test-objectsender | ||
- test-server | ||
- test-server-no-ff | ||
- test-preview-service | ||
|
||
- publish-helm-chart: | ||
filters: &filters-publish | ||
|
@@ -331,6 +343,7 @@ workflows: | |
- test-frontend-2 | ||
- test-viewer | ||
- test-objectsender | ||
- test-preview-service | ||
|
||
- publish-viewer-sandbox-cloudflare-pages: | ||
filters: *filters-publish | ||
|
@@ -579,8 +592,7 @@ jobs: | |
working_directory: 'packages/frontend-2' | ||
|
||
test-viewer: | ||
docker: &docker-node-browsers-image | ||
- image: cimg/node:18.19.0-browsers | ||
docker: *docker-node-browsers-image | ||
resource_class: large | ||
steps: | ||
- checkout | ||
|
@@ -617,9 +629,60 @@ jobs: | |
command: yarn test | ||
working_directory: 'packages/viewer' | ||
|
||
test-preview-service: | ||
docker: | ||
- image: cimg/node:18.19.0 | ||
- image: cimg/postgres:14.11 | ||
environment: | ||
POSTGRES_DB: preview_service_test | ||
POSTGRES_PASSWORD: preview_service_test | ||
POSTGRES_USER: preview_service_test | ||
resource_class: large | ||
environment: {} | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
name: Restore Yarn Package Cache | ||
keys: | ||
- yarn-packages-server-{{ checksum "yarn.lock" }} | ||
- run: | ||
name: Install Dependencies | ||
command: yarn | ||
|
||
- run: | ||
name: Install Dependencies v2 (.node files missing bug) | ||
command: yarn | ||
|
||
- save_cache: | ||
name: Save Yarn Package Cache | ||
key: yarn-packages-server-{{ checksum "yarn.lock" }} | ||
paths: | ||
- .yarn/cache | ||
- .yarn/unplugged | ||
|
||
- run: | ||
name: Build public packages | ||
command: yarn build:public | ||
|
||
- run: | ||
name: Lint everything | ||
command: yarn lint:ci | ||
working_directory: 'packages/preview-service' | ||
|
||
- run: | ||
name: Copy .env.example to .env | ||
command: | | ||
#!/usr/bin/env bash | ||
cp packages/preview-service/.env.example packages/preview-service/.env | ||
sed -i~ '/^PG_CONNECTION_STRING=/s/=.*/="postgres:\/\/preview_service_test:[email protected]:5432\/preview_service_test"/' packages/preview-service/.env | ||
- run: | ||
name: Run tests | ||
command: yarn test | ||
working_directory: 'packages/preview-service' | ||
|
||
test-objectsender: | ||
docker: &docker-node-browsers-image | ||
- image: cimg/node:18.19.0-browsers | ||
docker: *docker-node-browsers-image | ||
resource_class: large | ||
steps: | ||
- checkout | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
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 | ||
- packages/frontend-2/type-augmentations/stubs | ||
- packages/preview-service | ||
- packages/viewer | ||
- packages/objectloader | ||
- packages/shared | ||
|
||
jobs: | ||
preview-service-acceptance: | ||
name: Preview Service Acceptance test | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
# Docker Hub image | ||
image: postgres:14 | ||
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 | ||
|
||
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 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v4 | ||
name: Install pnpm | ||
with: | ||
version: 9 | ||
run_install: false | ||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'yarn' | ||
- name: Install dependencies | ||
working-directory: utils/preview-service-acceptance | ||
run: yarn install | ||
|
||
#TODO load the docker image from a previous job | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Build and load preview-service Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: ./packages/preview-service/Dockerfile | ||
load: true | ||
push: false | ||
tags: speckle/preview-service:local | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Run the acceptance test | ||
working-directory: packages/preview-service | ||
run: yarn test:acceptance | ||
env: | ||
PREVIEW_SERVICE_IMAGE: speckle/preview-service:local | ||
OUTPUT_FILE_PATH: /tmp/preview-service-output.png | ||
NODE_ENV: test | ||
PG_CONNECTION_STRING: postgres://preview_service_test:preview_service_test@localhost:5432/preview_service_test | ||
|
||
- uses: actions/upload-artifact@v4 | ||
name: Upload the output from the preview-service | ||
id: upload-preview-service-output | ||
with: | ||
name: preview-service-output | ||
path: /tmp/preview-service-output.png | ||
- 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 the following image:<br/><img src="${{ steps.upload-preview-service-output.outputs.artifact-url }}"/><br/>' | ||
}) |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.