-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (124 loc) · 3.66 KB
/
main.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
name: main
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Manual run from GitHub UI
workflow_dispatch:
# Wednesdays at 0400
# schedule:
# - cron: '0 4 * * 3'
permissions:
contents: write
packages: write
jobs:
build-and-test:
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [17]
env:
ENV_FILE: .env
# Below should be overwritten by .env
TORCH_VERSION: cpu
MODEL_NAME: hyp1231/blair-roberta-base
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load environment variables
run: cat ${{ env.ENV_FILE }} >> $GITHUB_ENV
- name: Use Java ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
cache: 'gradle'
distribution: 'liberica'
- name: Setup pdm
uses: pdm-project/setup-pdm@v4
- name: Restore cached venv
id: cache-venv-restore
uses: actions/cache/restore@v4
with:
path: |
.venv
key: venv-${{ runner.os }}-${{ hashFiles('pdm.lock') }}
restore-keys: |
venv-${{ runner.os }}-
venv-
- name: Install dependencies
run: |
pdm install
pdm install-${{ env.TORCH_VERSION }}
- name: Save venv to cache
id: cache-venv-save
uses: actions/cache/save@v4
with:
path: |
.venv
key: ${{ steps.cache-venv-restore.outputs.cache-primary-key }}
- name: Restore cached model files
id: cache-model-restore
uses: actions/cache/restore@v4
with:
path: |
data/models
key: models-${{ env.MODEL_NAME }}
- name: Download model files
run: make get-model
- name: Save model files to cache
id: cache-model-save
uses: actions/cache/save@v4
with:
path: |
data/models
key: ${{ steps.cache-model-restore.outputs.cache-primary-key }}
- name: Install
run: make deps
- name: Build
run: make docker-build
- name: Test
run: make test-ci
- name: Test is release
if: startsWith(github.event.head_commit.message, 'release:') && github.event_name == 'push'
id: isRelease
run: |
echo "value=true" >> $GITHUB_OUTPUT
- name: Get release version string
if: steps.isRelease.outputs.value
id: getVersion
env:
MESSAGE: ${{ github.event.head_commit.message }}
run: |
VALUE=$(echo "${MESSAGE}" | sed 's/release://' | sed 's/[[:space:]]*//g')
echo "value=${VALUE}" >> $GITHUB_OUTPUT
- name: Create tag
if: steps.isRelease.outputs.value
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.getVersion.outputs.value }}",
sha: context.sha
})
- name: Docker login
if: steps.isRelease.outputs.value
env:
GITHUB_REPOSITORY_OWNER: ${{ github.repository.owner }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make docker-login-github
- name: Tag Docker build
if: steps.isRelease.outputs.value
env:
GITHUB_REPOSITORY_OWNER: ${{ github.repository.owner }}
RELEASE_TAG: ${{ steps.getVersion.outputs.value }}
run: make docker-tag-github
- name: Push Docker build to container registry
if: steps.isRelease.outputs.value
env:
GITHUB_REPOSITORY_OWNER: ${{ github.repository.owner }}
RELEASE_TAG: ${{ steps.getVersion.outputs.value }}
run: make docker-push-github