-
Notifications
You must be signed in to change notification settings - Fork 1
150 lines (131 loc) · 4.44 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
140
141
142
143
144
145
146
147
148
149
150
name: CI
on:
push:
branches: [master]
tags: [v*]
pull_request:
branches: [master]
pull_request_target:
branches: [master]
jobs:
lint:
if: |
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') ||
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]')
name: Linter
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout commit
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Cache Python and its deps
uses: actions/cache@v3
with:
key: ${{ runner.os }}-python-3.11-${{ hashFiles('requirements/*.txt') }}
path: ${{ env.pythonLocation }}
- name: Cache pre-commit hooks
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-python-3.11-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install dependencies
run: |
python -m pip install -U pip
make setup
- name: Run linters
run: |
echo Linting ${{ github.event.pull_request.head.sha || github.sha }}
make lint
- name: Save the package version
id: version
run: |
echo "version=$(python setup.py --version)" >> $GITHUB_OUTPUT
test:
if: |
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') ||
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]')
name: Run test
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout commit
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Cache Python and its deps
uses: actions/cache@v3
with:
key: ${{ runner.os }}-python-3.11-${{ hashFiles('requirements/*.txt') }}
path: ${{ env.pythonLocation }}
- name: Cache pre-commit hooks
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-python-3.11-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install dependencies
run: |
python -m pip install -U pip
make setup
- name: Configure Neu.ro CLI
env:
NEURO_TOKEN: ${{ secrets.COOKIECUTTER_TEST_E2E_TOKEN }}
NEURO_STAGING_URL: ${{ secrets.NEURO_STAGING_URL }}
run: |
apolo config login-with-token ${{ env.NEURO_TOKEN }} ${{ env.NEURO_STAGING_URL }}
apolo config switch-cluster onprem-poc
- name: Run tests
env:
WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }}
run: |
make test
deploy:
name: Build and push Docker image
needs: [lint, test]
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- name: Checkout commit
uses: actions/checkout@v3
- name: Sanity check for tag and version
run: |
export VERSION=${{ needs.lint.outputs.version }}
if [ "${{ github.ref }}" != "refs/tags/v$VERSION" ]
then
echo "Git tag '${{ github.ref }}' differs from hard-coded package version 'v$VERSION'"
exit 1
else
echo "OK, git tag matches hard-coded package version: 'v$VERSION'"
fi
- name: Login to Github container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
env:
VERSION: ${{ needs.lint.outputs.version }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
docker build \
-t "ghcr.io/neuro-inc/wabucketref:${VERSION}" \
-t "ghcr.io/neuro-inc/wabucketref:latest" \
--build-arg COMMIT_SHA=${COMMIT_SHA} \
.
- name: Push
env:
VERSION: ${{ needs.lint.outputs.version }}
run: |
docker push ghcr.io/neuro-inc/wabucketref --all-tags