-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (155 loc) · 4.68 KB
/
devel.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
name: "UnitTests and Build Docker Dev. Image"
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
on:
push:
branches:
- main
- master
pull_request:
paths:
- "nuvla/**"
- "tests/**"
- "scripts/**"
- ".github/workflows/devel.yml"
- "pyproject.toml"
- "poetry.lock"
- "Dockerfile"
workflow_dispatch:
jobs:
run-unittests:
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local # the path depends on the OS
key: poetry-0 # increment to reset cache
- name: Setup Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Generate test requirements
run: >
poetry export
-f requirements.txt
-o requirements.test.txt
--without-hashes
--without-urls
--with test
--with server
- name: Install TOX
run: |
pip install tox
- name: Run Unittests
id: unittests-run
run: |
tox
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: test-report.xml
# - name: SonarCloud Scan
# uses: SonarSource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
build-package:
needs: run-unittests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local # the path depends on the OS
key: poetry-0 # increment to reset cache
- name: Setup Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Build Package
run: |
poetry build --format=wheel --no-interaction
cp ./dist/*.whl ./dist/nuvla_job_engine-latest-py3-none-any.whl
- name: Generate server requirements
run: >
poetry export
-f requirements.txt
-o dist/requirements.txt
--without-hashes
--without-urls
--with server
- name: Save wheel
uses: actions/upload-artifact@v4
with:
name: freeze
path: dist/
build-job-engine:
needs: build-package
runs-on: ubuntu-latest
steps:
- name: Set env
shell: bash
run: echo "BUILD_TIME=$(date --utc +%FT%T.%3NZ)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: freeze
path: dist/
- name: SetUp QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.SIXSQ_DOCKER_USERNAME }}
password: ${{ secrets.SIXSQ_DOCKER_PASSWORD }}
- name: Extract branch name and substitute slashes
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | tr '/' '-' >> $GITHUB_OUTPUT
id: extract_branch
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
build-args: |
GIT_BRANCH=${{ github.head_ref || github.ref_name }}
GIT_BUILD_TIME=${{ env.BUILD_TIME }}
GIT_COMMIT_ID=${{ github.sha }}
GITHUB_RUN_NUMBER=${{ github.run_number }}
GITHUB_RUN_ID=${{ github.run_id }}
PROJECT_URL=${{ github.server_url }}/${{ github.repository }}
PACKAGE_NAME=${{ env.PACKAGE_NAME }}
PACKAGE_TAG=latest
push: true
tags: >
nuvladev/job:${{ steps.extract_branch.outputs.branch }}
cache-from: type=gha
cache-to: type=gha,mode=max