-
Notifications
You must be signed in to change notification settings - Fork 4
167 lines (140 loc) · 5.62 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
name: Ataru
on:
workflow_dispatch:
push:
paths-ignore:
- '**.md'
permissions:
id-token: write
contents: read
env:
HUSKY: 0
jobs:
test-integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare-clojure-env
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OPH_UTILITY_ROLE_ARN }}
aws-region: eu-west-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Cache Docker images
uses: ScribeMD/docker-cache@0.5.0
with:
key: docker-${{ runner.os }}-${{ hashFiles('**/workflows/build.yml', '**/Dockerfile', '**/docker-compose.yml') }}
- name: Npm ci
run: npm ci
- name: Get installed Playwright version
id: playwright-version
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').dependencies['@playwright/test'].version)")" >> $GITHUB_ENV
- name: Cache playwright binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
- run: npx playwright install --with-deps chromium
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Prepare tests
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
GA_BUILD_NUMBER: ${{ github.run_number }}
run: |
git clone https://github.com/Opetushallitus/ci-tools.git
source ci-tools/common/setup-tools.sh
docker run -d --name ataru-test-db -p 5433:5432 -e POSTGRES_DB=ataru-test -e POSTGRES_PASSWORD=oph -e POSTGRES_USER=oph $(docker build -f ./test-postgres/Dockerfile --build-arg POSTGRESQL_VERSION=15 -q .)
docker run -d --name ataru-test-redis -p 6380:6379 $REGISTRY/ecr-public/docker/library/redis:7
docker run -d --name ataru-test-ftpd -p 2221:21 -p 30000-30009:30000-30009 $REGISTRY/utility/hiekkalaatikko:ataru-test-ftpd
- name: Run integration tests (Cypress & Playwright)
run: |
./bin/cibuild.sh run-browser-tests-integration
test-spec-and-mocha:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare-clojure-env
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OPH_UTILITY_ROLE_ARN }}
aws-region: eu-west-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Prepare tests
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
GA_BUILD_NUMBER: ${{ github.run_number }}
run: |
sudo apt-get update
sudo apt-get install -y lftp
git clone https://github.com/Opetushallitus/ci-tools.git
source ci-tools/common/setup-tools.sh
docker run -d --name ataru-test-db -p 5433:5432 -e POSTGRES_DB=ataru-test -e POSTGRES_PASSWORD=oph -e POSTGRES_USER=oph $(docker build -f ./test-postgres/Dockerfile --build-arg POSTGRESQL_VERSION=15 -q .)
docker run -d --name ataru-test-redis -p 6380:6379 $REGISTRY/ecr-public/docker/library/redis:7
docker run -d --name ataru-test-ftpd -p 2221:21 -p 30000-30009:30000-30009 $REGISTRY/utility/hiekkalaatikko:ataru-test-ftpd
- name: Run Spec and Mocha tests
run: |
./bin/cibuild.sh run-spec-and-mocha-tests
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare-clojure-env
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Build
run: ./bin/cibuild.sh create-both-uberjars
- uses: actions/cache@v4
id: restore-build
with:
path: target
key: ${{ github.sha }}
build-and-deploy-ataru-hakija:
needs: [test-integration, test-spec-and-mocha, build]
uses: Opetushallitus/.github/.github/workflows/push-scan-java-ecr.yml@main
with:
application: ataru-hakija
base-image: baseimage-fatjar-openjdk17:master
configfolder: oph-configuration
jarfile: ataru
secrets:
AWS_UTILITY_ROLE_ARN: ${{ secrets.AWS_OPH_UTILITY_ROLE_ARN }}
build-and-deploy-ataru-editori:
needs: [test-integration, test-spec-and-mocha, build]
uses: Opetushallitus/.github/.github/workflows/push-scan-java-ecr.yml@main
with:
application: ataru-editori
base-image: baseimage-fatjar-openjdk17:master
configfolder: oph-configuration
jarfile: ataru
secrets:
AWS_UTILITY_ROLE_ARN: ${{ secrets.AWS_OPH_UTILITY_ROLE_ARN }}
build-and-deploy-ovara-ataru:
needs: [test-integration, test-spec-and-mocha, build]
uses: Opetushallitus/.github/.github/workflows/push-scan-java-ecr.yml@main
with:
application: ovara-ataru
base-image: baseimage-fatjar-openjdk17:master
configfolder: ovara-configuration
jarfile: ovara-ataru
secrets:
AWS_UTILITY_ROLE_ARN: ${{ secrets.AWS_OPH_UTILITY_ROLE_ARN }}