-
Notifications
You must be signed in to change notification settings - Fork 6
122 lines (104 loc) · 3.37 KB
/
build.yml
File metadata and controls
122 lines (104 loc) · 3.37 KB
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
name: Build
on: [push, workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo "Building .."
test-setup:
needs: build
runs-on: ubuntu-latest
outputs:
testmo-run-id: ${{ steps.run-tests.outputs.testmo-run-id }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 19
cache: npm
- run: npm ci
# Optionally add a couple of fields such as the git hash and link to the build
- run: |
npx testmo automation:resources:add-field --name git --type string \
--value ${GITHUB_SHA:0:7} --resources resources.json
RUN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
npx testmo automation:resources:add-link --name build \
--url $RUN_URL --resources resources.json
# Check if the required variables are available
- run: |
if [[ -z "${TESTMO_URL}" ]]; then
echo "The TESTMO_URL secret is not defined for this repository"
exit 1
fi
if [[ -z "${TESTMO_TOKEN}" ]]; then
echo "The TESTMO_TOKEN secret is not defined for this repository"
exit 1
fi
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
# Create test run
- run: |
npx testmo automation:run:create \
--instance "$TESTMO_URL" \
--project-id 1 \
--name "Parallel mocha test run" \
--resources resources.json \
--source "unit-tests" > testmo-run-id.txt
ID=$(cat testmo-run-id.txt)
echo "testmo-run-id=$ID" >> $GITHUB_OUTPUT
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
id: run-tests
test:
needs: test-setup
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ci_index: [0, 1, 2, 3]
ci_total: [4]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 19
cache: npm
- run: npm ci
# Run automated tests and report results to Testmo
- run: |
npx testmo automation:run:submit-thread \
--instance "$TESTMO_URL" \
--run-id "${{ needs.test-setup.outputs.testmo-run-id }}" \
--results results/*.xml \
-- npm run mocha-junit-parallel # Note space after --
env:
CI_TOTAL: ${{ matrix.ci_total }}
CI_INDEX: ${{ matrix.ci_index }}
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
test-complete:
needs: [test-setup, test]
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 19
cache: npm
- run: npm ci
# Mark test run completed
- run: |
npx testmo automation:run:complete \
--instance "$TESTMO_URL" \
--run-id "${{ needs.test-setup.outputs.testmo-run-id }}"
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
deploy:
needs: [test, test-complete]
runs-on: ubuntu-latest
steps:
- run: echo "Deploying .."