-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (128 loc) · 4.34 KB
/
cicd.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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python package
on:
push:
branches: [ "main", "release" ]
pull_request:
branches: [ "main", "release" ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Set up pre-commit
run: python -m pip install pre-commit && pre-commit install
- name: Run pre-commit
run: pre-commit run --all-files
test:
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install ".[test]"
- name: Test with pytest
run: |
pytest
- name: Codecov
# You may pin to the exact commit or the version.
# uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
uses: codecov/codecov-action@v3.1.4
with:
# Specify whether the Codecov output should be verbose
verbose: true # optional
docker_test:
runs-on: ubuntu-latest
needs: [lint]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install ".[build]"
- name: build wheel
run: python -m build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Docker Setup
- name: Build Docker image
id: dockerbuild
run: |
docker build -t ghcr.io/talusbio/flimsay:v$(python -c "import flimsay ; print(flimsay.__version__)") .
# Quick test on the docker image
- name: Test Docker image
run: |
docker run --rm -v ${PWD}:/data/ \
ghcr.io/talusbio/flimsay:v$(python -c "import flimsay ; print(flimsay.__version__)") \
flimsay fill_blib /data/tests/unit_tests/data/test.blib /data/out.blib
publish:
runs-on: ubuntu-latest
if: startsWith(github.event_name, 'push') && startsWith(github.ref, 'refs/heads/release')
needs: [lint, test, docker_test]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install ".[build]"
- name: Set up quarto
uses: quarto-dev/quarto-actions/setup@v2
- name: Render README
run: quarto render README.qmd
- name: build wheel
run: python -m build
- name: pypi-publish
uses: pypa/gh-action-pypi-publish@v1.8.8
with:
# Password for your PyPI user or an access token
password: ${{ secrets.PYPI_TOKEN }} # optional
# The target directory for distribution
packages-dir: dist # optional
# Show verbose output.
verbose: true # optional, default is false
skip-existing: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to the GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Docker Setup
- name: Build Docker image
id: dockerbuild
run: |
docker build -t ghcr.io/talusbio/flimsay:v$(python -c "import flimsay ; print(flimsay.__version__)") .
# Quick test on the docker image
- name: Test Docker image
run: |
docker run --rm -v ${PWD}:/data/ ghcr.io/talusbio/flimsay:v$(python -c "import flimsay ; print(flimsay.__version__)") \
flimsay fill_blib /data/tests/unit_tests/data/test.blib /data/out.blib
# Publish Docker
- name: Push the Docker image to the GHCR
id: ghcr_push
run: |
docker push ghcr.io/talusbio/flimsay:v$(python -c "import flimsay ; print(flimsay.__version__)")