-
Notifications
You must be signed in to change notification settings - Fork 181
93 lines (86 loc) · 3.13 KB
/
preview-service-acceptance.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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:
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/>'
})