-
Notifications
You must be signed in to change notification settings - Fork 356
107 lines (104 loc) · 3.96 KB
/
build-and-test.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Build and Test
on:
workflow_dispatch:
push:
merge_group:
env:
IMAGE_REPOSITORY: "us-east1-docker.pkg.dev/the-coral-project/coral/talk"
IMAGE_CACHE_REPOSITORY: "coralproject/ci"
DOCKERHUB_USERNAME: "coralproject"
jobs:
build-and-test:
name: Build and Test
runs-on: coral-ci
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: webfactory/ssh-agent@v0.7.0
with:
ssh-private-key: ${{ secrets.REPO_PATCHED_DEPLOY_KEY }}
- name: Login to GAR
uses: docker/login-action@v2
with:
registry: us-east1-docker.pkg.dev
username: _json_key
password: ${{ secrets.GAR_JSON_KEY }}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Define SHORT_SHA with commit short sha
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
- name: Setup Node18.x
uses: actions/setup-node@v3
with:
node-version: "18.16.x"
- name: Install pnpm 8
run: npm install -g pnpm@8.14.3 --registry=https://registry.npmjs.org
# -
# name: npm Lockfile Version (client)
# uses: mansona/npm-lockfile-version@v1
# with:
# entryPoint: ./client
# version: 2
# -
# name: npm Lockfile Version (common)
# uses: mansona/npm-lockfile-version@v1
# with:
# entryPoint: ./common
# version: 2
# -
# name: npm Lockfile Version (server)
# uses: mansona/npm-lockfile-version@v1
# with:
# entryPoint: ./server
# version: 2
- name: pnpm ci
run: sh scripts/pnpm-ci.sh
- name: Generate schemas and types
run: sh scripts/generate.sh
- name: Lint Source Code
run: sh scripts/lint.sh
- name: Lint Versions
run: |
cd client
npx @coralproject/package-version-lint
- name: Run Server Unit Tests
run: cd server && pnpm run test:server -- --ci --reporters=default --reporters=jest-junit
- name: Run Client Stream Unit Tests
run: cd client && npm run test:client:stream -- --ci --reporters=default --reporters=jest-junit
- name: Run Client Admin Unit Tests
run: cd client && npm run test:client:admin -- --ci --reporters=default --reporters=jest-junit
- name: Run Client Other Unit Tests
run: cd client && npm run test:client:other -- --ci --reporters=default --reporters=jest-junit
- name: Build
env:
NODE_OPTIONS: "--max-old-space-size=14336"
run: sh scripts/build.sh
- name: Verify Bundle Size
run: cd client && ./node_modules/.bin/bundlesize --enable-github-checks
# Build tag push the image after a merge to develop
- name: Build, Tag, Push
uses: docker/build-push-action@v5
if: github.ref == 'refs/heads/develop'
with:
push: true
tags: ${{ env.IMAGE_REPOSITORY }}:develop-latest
build-args: |
REVISION_HASH=${GITHUB_SHA}
cache-from: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-develop
cache-to: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-develop
# Build tag push the release candidate image when the branch name begins with release-
- name: Build, Tag, Push RC
uses: docker/build-push-action@v5
if: startsWith( github.ref, 'refs/heads/release-')
with:
push: true
tags: ${{ env.IMAGE_REPOSITORY }}:${{ github.ref_name }}-${{ env.SHORT_SHA }}
build-args: |
REVISION_HASH=${GITHUB_SHA}
cache-from: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-release
cache-to: type=registry,ref=${{ env.IMAGE_CACHE_REPOSITORY }}:cache-release