-
Notifications
You must be signed in to change notification settings - Fork 6
149 lines (130 loc) · 4.33 KB
/
ci.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Java CI
on: [push]
jobs:
setup:
runs-on: ubuntu-latest
outputs:
test-chunks: ${{ steps['set-test-chunks'].outputs['test-chunks'] }}
test-chunk-ids: ${{ steps['set-test-chunk-ids'].outputs['test-chunk-ids'] }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'
- run: yarn install
# Steps being performed here:
# npx jest --listTests: List all of the available tests.
# shuf: Shuffle the list randomly.
# awk NF: Remove additional empty lines.
# jq -R .: Convert each line to a JSON string.
# jq -s .: Combine them all into a single JSON array.
# jq -cM ...: This part will split it into 8 groups. The last group will probably not have enough to fill the full group.
- id: set-test-chunks
name: split tests into chunks
run: echo "test-chunks=$(npx jest --listTests | shuf | awk NF | jq -R . | jq -s . | jq -cM '[_nwise(length / 7 | floor)]')" >> $GITHUB_OUTPUT
- id: set-test-chunk-ids
name: Set Chunk IDs
run: echo "test-chunk-ids=$(echo $CHUNKS | jq -cM 'to_entries | map(.key)')" >> $GITHUB_OUTPUT
env:
CHUNKS: ${{ steps['set-test-chunks'].outputs['test-chunks'] }}
test-chunk:
runs-on: ubuntu-latest
name: run tests (Chunk ${{ matrix.chunk }})
needs:
- setup
strategy:
fail-fast: false
matrix:
chunk: ${{ fromJson(needs.setup.outputs['test-chunk-ids']) }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'
- run: yarn install
- name: Run all tests in chunk
run: echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | @text' | xargs npx jest
env:
CHUNKS: ${{ needs.setup.outputs['test-chunks'] }}
build:
runs-on: ubuntu-latest
needs:
- setup
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'
- name: Install
run: |
yarn install
- name: Build UI project
run: |
yarn workspace dina-ui build
- name: Extract Version
if: ${{ github.ref == 'refs/heads/master' }}
run: |
jq -r ".version" packages/dina-ui/package.json > version.txt
- name: Store artifacts
if: ${{ github.ref == 'refs/heads/master' }}
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
packages/dina-ui/prod.Caddyfile
packages/dina-ui/out
Dockerfile
version.txt
push:
name: Build Docker Image and Push to DockerHub
needs: [build]
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
steps:
- name: Download artifacts from build job
uses: actions/download-artifact@v4
with:
name: build-artifacts
- name: Set VERSION_TAG ENV variable
run: |
echo "VERSION_TAG=$(cat version.txt)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Image and Push
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: aafcbicoe/dina-ui:${{ env.VERSION_TAG }}
provenance: false
build-docs:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Building ascii docs
run: |
yarn install
yarn docs
- name: Copy images for UI dev docs
run: |
mkdir generated-docs/images
cp -r ./docs/images generated-docs
- name: Deploy GitHub Pages (only on master branch)
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: generated-docs