-
Notifications
You must be signed in to change notification settings - Fork 30
191 lines (165 loc) · 5.89 KB
/
build.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Continuous integration
on:
push:
paths-ignore:
- "CHANGELOG.adoc"
- "docker-compose.yml"
- ".github/PULL_REQUEST_TEMPLATE.md"
- "doc/**"
branches:
- "**"
tags:
- "*"
pull_request:
paths-ignore:
- "CHANGELOG.adoc"
- "docker-compose.yml"
- ".github/PULL_REQUEST_TEMPLATE.md"
- "doc/**"
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
attestations: write
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- name: Checkout
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
fetch-depth: 0
- name: Checkout
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Node SDK
uses: actions/setup-node@v4
with:
node-version: 18.7
registry-url: https://npm.pkg.github.com/
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Setup Java SDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "temurin"
- name: Setup some global environment variables
run: |
echo "git_describe=$(git describe --always)" >> $GITHUB_ENV
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build the frontend packages
run: |
echo "//npm.pkg.github.com/:_authToken=${{ github.token }}" >> .npmrc
echo "CI=true" >> $GITHUB_ENV
npm ci
npm run build
- name: Check that the frontend dependencies are ok
env:
GITHUB_EVENT: ${{ toJSON(github.event) }}
run: node scripts/check-frontend-dependencies.js
- name: Copy frontend artifacts
run: |
mkdir -p backend/application/syson-frontend/src/main/resources/static
cp -R frontend/syson/dist/* backend/application/syson-frontend/src/main/resources/static
- name: Build the backend
env:
USERNAME: ${{github.actor}}
PASSWORD: ${{secrets.GITHUB_TOKEN}}
run: mvn -U -B -e clean verify --settings settings.xml
- name: Archive the code coverage results
run: tar -cf coverage.tar backend/releng/syson-test-coverage/target/site/jacoco-aggregate
- name: Store code coverage results
uses: actions/upload-artifact@v4
if: always()
with:
name: jacoco
path: coverage.tar
retention-days: 5
- name: Check the global code coverage
run: jshell scripts/check-coverage.jsh
- name: Publish the backend
if: startsWith(github.ref, 'refs/tags/v')
env:
USERNAME: ${{github.actor}}
PASSWORD: ${{secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: mvn -B deploy -DskipTests --settings settings.xml
- name: Publish the frontend packages
if: startsWith(github.ref, 'refs/tags/v')
run: |
npm publish --workspaces
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: eclipsesyson/syson
- name: Set up Docker Buildx to use cache feature
uses: docker/setup-buildx-action@v3
- name: Build Docker image
id: load
uses: docker/build-push-action@v6
with:
context: backend/application/syson-application
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Check the integration test code
run: |
npm ci
npm run eslint
working-directory: integration-tests
- name: Run end to end tests against the application
if: startsWith(github.ref, 'refs/tags/v') == false && github.ref != 'refs/heads/master'
uses: cypress-io/github-action@v6
with:
build: docker compose -f docker-compose-integration-tests.yml up -d
start: docker compose -f docker-compose-integration-tests.yml ps
wait-on: "http://localhost:8080"
wait-on-timeout: 180
working-directory: integration-tests
record: false
env:
IMAGE_TAG: eclipsesyson/syson:${{ steps.meta.outputs.version }}
GITHUB_TOKEN: ${{ github.token }}
- name: Store Cypress screenshots
uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-screenshots
path: integration-tests/target/screenshots/**/*.png
retention-days: 5
- name: Log in to Docker Hub
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
uses: docker/login-action@v3
with:
username: ${{ secrets.ORG_DOCKER_HUB_USER }}
password: ${{ secrets.ORG_DOCKER_HUB_TOKEN }}
- name: Push Docker image
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
id: push
uses: docker/build-push-action@v6
with:
context: backend/application/syson-application
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}