-
Notifications
You must be signed in to change notification settings - Fork 9
137 lines (133 loc) · 5.44 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
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Build aissemble
on:
workflow_dispatch:
inputs:
buildBranch:
description: "Branch you want to build"
required: true
type: string
default: "dev"
push:
branches: [ "dev" ]
schedule:
- cron: "0 6 * * *" # every day at 6am UTC
jobs:
build:
runs-on: arc-runner-set-aissemble
env:
DOCKER_CONFIG: /home/runner/.docker
RUNS_ON_S3_BUCKET_CACHE: aissemble-github-cache
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.buildBranch }}
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.S3_CACHE_USER }}
aws-region: ${{ secrets.AWS_REGION }}
mask-aws-account-id: true
# 3 hours, as our nightly takes ~ 2
role-duration-seconds: 10800
- name: clear cache on nightly build
if: ${{ github.event.schedule }}
uses: actions/github-script@v6
with:
script: |
console.log("Clearing cache")
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
})
for (const cache of caches.data.actions_caches) {
console.log(cache)
github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
}
console.log("Clear completed")
- name: Install dependencies
uses: ./.github/actions/install_dependencies
with:
docker-username: ${{ secrets.DOCKERHUB_USERNAME }}
docker-token: ${{ secrets.DOCKERHUB_TOKEN }}
#NB: We restore/save cache manually so that we save the cache even if the build fails
- name: Load docker build cache
id: cached-docker-build
uses: runs-on/cache/restore@v4
with:
path: ~/.docker/cache
key: docker-cache-${{ hashFiles('**/Dockerfile') }}
restore-keys: |
docker-cache-
- name: Load m2 repository cache # Manually caching .m2 repo as the setup-java caching isn't falling back to older caches
id: cached-m2-repo
uses: runs-on/cache/restore@v4
with:
path: ~/.m2/repository
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-
- name: Load m2 build cache
id: cached-m2-build
uses: runs-on/cache/restore@v4
with:
path: ~/.m2/build-cache
key: maven-build-cache-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-build-cache-
#NB: Not saving poetry cache on failure in case it's a failure caused by an in-flight python package release
- name: Poetry cache
id: cached-poetry
uses: runs-on/cache@v4
with:
path: ~/.cache/pypoetry
key: poetry-cache-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
poetry-cache-
# Generate the settings.xml for ghcr.io, pypi, & dev-pypi server profiles
- name: Create settings.xml
run: |
echo "<settings><servers><server><id>ghcr.io</id><username>${{ secrets.GHCR_IO_USERNAME }}</username><password>${{ secrets.GHCR_IO_TOKEN }}</password></server><server><id>pypi</id><username>${{ secrets.PYPI_USERNAME }}</username><password>${{ secrets.PYPI_TOKEN }}</password></server><server><id>dev-pypi</id><username>${{ secrets.TEST_PYPI_USERNAME }}</username><password>${{ secrets.TEST_PYPI_TOKEN }}</password></server> </servers></settings>" > $HOME/.m2/settings.xml
# Run build with the gh-build profile
- name: Build aiSSEMBLE
run: |
./mvnw -B clean deploy -U -file pom.xml -Pci,integration-test,gh-build --settings $HOME/.m2/settings.xml
# Install Maven which is needed for archetype tests
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
# Execute archetype tests
- name: Run Archetype Tests
run: |
./mvnw -B clean install -Parchetype-test -pl :foundation-archetype
- name: Save docker build cache
id: save-docker-build
uses: runs-on/cache/save@v4
if: always() && steps.cached-docker-build.outputs.cache-hit != 'true'
with:
path: ~/.docker/cache
key: docker-cache-${{ hashFiles('**/Dockerfile') }}
- name: Save m2 repository cache
id: save-m2-repo
uses: runs-on/cache/save@v4
if: always() && steps.cached-m2-repo.outputs.cache-hit != 'true'
with:
path: ~/.m2/repository
key: maven-${{ hashFiles('**/pom.xml') }}
- name: Save m2 build cache
id: save-m2-build
uses: runs-on/cache/save@v4
if: always() && steps.cached-m2-build.outputs.cache-hit != 'true'
with:
path: ~/.m2/build-cache
key: maven-build-cache-${{ hashFiles('**/pom.xml') }}