-
Notifications
You must be signed in to change notification settings - Fork 8
185 lines (146 loc) · 4.86 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
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
183
184
185
# Run all tests, linters, code analysis and other QA tasks on
# every push to main and PRs.
#
# To SSH into the runner to debug a failure, add the following step before
# the failing step
# - uses: lhotari/action-upterm@v1
# with:
# limit-access-to-actor: true
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
tags:
- '*'
# Prevent multiple jobs running after fast subsequent pushes
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
pure_tests:
name: Pure Tests
strategy:
matrix:
python: ["python39", "python310", "python311"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
- uses: cachix/cachix-action@v12
with:
name: niteo-public
authToken: '${{ secrets.CACHIX_AUTH_TOKEN_PUBLIC }}'
- name: Run linters and unit tests the Nix way
env:
PYTHON: ${{ matrix.python }}
run: |
nix build .#devShell.x86_64-linux.default-$(echo $PYTHON)
nix build .#packages.x86_64-linux.default-$(echo $PYTHON)
nix build .#checks.x86_64-linux.pre-commit-$(echo $PYTHON)
nix build .#checks.x86_64-linux.tests-$(echo $PYTHON)
impure_tests:
name: Impure Tests
# strategy:
# matrix:
# python-version: ["3.9", "3.10", "3.11"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup upterm session
uses: lhotari/action-upterm@v1
# - name: Build Docker image
# uses: docker/build-push-action@v5
# with:
# context: .
# push: false
# tags: tesh
# - uses: docker/build-push-action@v2
# with:
# context: .
# tags: tesh
# push: false
# - uses: addnab/docker-run-action@v3
# with:
# image: tesh
# run: echo "hello world"
# - uses: addnab/docker-run-action@v3
# with:
# image: tesh
# run: pwd
# - uses: addnab/docker-run-action@v3
# with:
# image: tesh
# run: nix develop --command bash -c "tesh --version"
# - uses: addnab/docker-run-action@v3
# with:
# image: tesh
# run: nix develop --command bash -c "make unit"
# - uses: addnab/docker-run-action@v3
# with:
# image: tesh
# run: nix develop --command bash -c "make tests"
- run: docker build -t tesh .
- run: docker run -d --rm -v .:/tesh --name tesh -it tesh
- run: docker exec tesh nix develop -c make tests
# - run: docker exec -it tesh make tests
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
# - name: Install Poetry
# uses: snok/install-poetry@v1
# - name: Install Poetry environment
# env:
# PYTHON: python${{ matrix.python-version }}
# run: |
# poetry env use $PYTHON
# poetry install
# - name: Install test dependencies
# run: sudo apt-get -y install nmap
# - name: Run linters and unit tests the Poetry way
# run: |
# # make lint -> pre-commit-config.yaml is managed by Nix,
# # so path entries won't work in Poetry env
# source $(poetry env info --path)/bin/activate
# make types
# make unit
# make tesh
# - uses: cachix/install-nix-action@v22
# - name: Run 'make examples'
# run: poetry run tesh examples/
release:
name: Release
needs: [pure_tests, impure_tests]
# To test publishing to testpypi:
# * comment out "verify git tag matches pyproject.toml version"
# * uncomment "with: repository-url: https://test.pypi.org/legacy/"
if:
github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
- uses: cachix/cachix-action@v12
with:
name: niteo-public
authToken: '${{ secrets.CACHIX_AUTH_TOKEN_PUBLIC }}'
- name: Verify git tag matches pyproject.toml version
run: |
GIT_VERSION=$GITHUB_REF_NAME
POETRY_VERSION=`nix-shell --run "poetry version --short"`
echo $GIT_VERSION
echo $POETRY_VERSION
[[ "$GIT_VERSION" == "$POETRY_VERSION" ]] && exit 0 || exit 1
- name: Build tesh wheel
run: |
nix-shell --run "poetry build"
- name: Upload wheel to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/