-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (137 loc) · 4.46 KB
/
ci.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
name: 'Run tests for ci cd'
on:
push:
branches: [ main ]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches: [ main ]
env:
is_package: true
publish_docker: true
jobs:
test-docker:
runs-on: ubuntu-latest
env:
tag: "helpmefindaname/ner-eval-dashboard-${{ github.sha }}:latest"
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Free Disk space
shell: bash
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver: docker
- name: Build docker image
uses: docker/build-push-action@v4
id: docker-build
with:
context: .
load: true
push: false
build-args: |
BUILD=test
# cache-from: type=gha
# cache-to: type=gha,mode=max
tags: ${{ env.tag }}
- name: run tests in docker
uses: addnab/docker-run-action@v3
with:
shell: bash
image: ${{env.tag}}
run: pytest -vv
prep-vars:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-vars.outputs.matrix }}
publish_docker: ${{ steps.set-vars.outputs.publish_docker }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- id: set-vars
run: |
echo ::set-output name=matrix::{\"python-version\":${{ env.is_package && '[ \"3.8\", \"3.9\", \"3.10\" ]' || '[ \"3.10\" ]' }} }
echo ::set-output name=publish_docker::${{env.publish_docker}}
test:
runs-on: ubuntu-latest
needs: prep-vars
strategy:
fail-fast: false
matrix: ${{fromJson(needs.prep-vars.outputs.matrix)}}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- name: setup python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install Dependencies
run: poetry install
- name: download nltk
run: poetry run python -c 'import nltk;nltk.download("punkt")'
- name: Run tests
run: poetry run pytest -vv
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest
needs: [test, test-docker]
if: startsWith(github.ref, 'refs/tags')
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- name: setup python ${{ env.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-version }}
cache: 'poetry'
- name: Install Dependencies
run: poetry install
- name: Set the right version
run: poetry version ${{ github.ref_name }}
- name: Build a binary wheel and a source tarball
run: poetry build
- name: Publish
if: ${{env.is_package}}
run: poetry publish -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} -vv
publish-docker:
name: Publish docker file and push it to a registry
runs-on: ubuntu-latest
needs: [test, test-docker, prep-vars]
if: needs.prep-vars.outputs.publish_docker && startsWith(github.ref, 'refs/tags')
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Save tag name
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: buildx-${{ github.sha }}
restore-keys: |
buildx-
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
cache-from: type=local,src=/tmp/.buildx-cache
push: true
tags: |
helpmefindaname/ner-eval-dashboard:${{ env.RELEASE_VERSION }}
helpmefindaname/ner-eval-dashboard:latest