-
Notifications
You must be signed in to change notification settings - Fork 1
121 lines (100 loc) · 3.7 KB
/
check_n_push_image.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
name: Check source code and push created image based on sources
on:
push:
branches:
- main
tags:
- 'v*'
paths-ignore:
- 'docs/**'
- '**.md'
pull_request:
paths-ignore:
- 'docs/**'
- '**.md'
workflow_dispatch:
jobs:
check-code:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Lint with ruff and pyright
run: |
make substitute-sources
pip install $(python3 setup.py --install-requirements)
pip install $(python3 setup.py --build-requirements)
pip install --requirement docs/notebooks/requirements.txt
pip install pre-commit==3.4.0
make pre-commit
docker-build-test-autotest:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Provide environment variable for autotests
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
echo "ACCESS_TOKEN=${ACCESS_TOKEN}" > .env
- name: Provides release environment variable if created new tag.
if: ${{ startsWith(github.event.ref, 'refs/tags/v') }}
run: |
echo "IS_DEVELOPED=0" >> .env
- name: Get current util version
id: get_version
run: |
echo "::set-output name=version::$(grep --max-count 1 UTIL_VERSION Makefile | grep -Eo "[0-9]+[.][0-9]+[.][0-9]+")"
- name: Create main docker image, run tests and save image for the next job
run: |
export $(cat .env | xargs)
make docker-image DOCKER_TAG=${{ secrets.DOCKER_HUB_USERNAME }}/codeplag-ubuntu22.04:${{ steps.get_version.outputs.version }}
docker image save --output /tmp/codeplag-ubuntu22.04.tar ${{ secrets.DOCKER_HUB_USERNAME }}/codeplag-ubuntu22.04:${{ steps.get_version.outputs.version }}
- name: Run autotests
run: |
export $(cat .env | xargs)
make docker-autotest
- name: Save created deb package
uses: actions/upload-artifact@v4
with:
name: deb-package
path: debian/deb/
retention-days: 3
if-no-files-found: error
- name: Upload created image
if: ${{ startsWith(github.event.ref, 'refs/tags/v') }}
uses: actions/upload-artifact@v4
with:
name: codeplag-ubuntu22.04
path: /tmp/codeplag-ubuntu22.04.tar
retention-days: 1
if-no-files-found: error
push-image:
runs-on: ubuntu-22.04
needs: [check-code, docker-build-test-autotest]
if: startsWith(github.event.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download created in the previous stage image
uses: actions/download-artifact@v4
with:
name: codeplag-ubuntu22.04
path: /tmp
- name: Get current util version
id: get_version
run: |
echo "::set-output name=version::$(grep --max-count 1 UTIL_VERSION Makefile | grep -Eo "[0-9]+[.][0-9]+[.][0-9]+")"
- name: Load Docker created image
run: |
docker load --input /tmp/codeplag-ubuntu22.04.tar
docker image tag ${{ secrets.DOCKER_HUB_USERNAME }}/codeplag-ubuntu22.04:${{ steps.get_version.outputs.version }} ${{ secrets.DOCKER_HUB_USERNAME }}/codeplag-ubuntu22.04:latest
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Push docker image
run: docker image push --all-tags ${{ secrets.DOCKER_HUB_USERNAME }}/codeplag-ubuntu22.04