-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (109 loc) · 3.25 KB
/
python-cicd.yml
File metadata and controls
136 lines (109 loc) · 3.25 KB
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
# This workflow will upload a Python Package to PyPI when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Python CICD
on:
push:
branches:
- '**'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- '**'
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: 'pip'
- name: Install Poetry
run: |
python3 -m pip install --upgrade pip
python3 -m pip install poetry
- name: Configure Poetry (in-project venv)
run: |
poetry config virtualenvs.in-project true
- name: Cache virtualenv
id: poetry-cache
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.poetry-cache.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-ansi
- name: Test format
run: |
poetry run black --check src/ecsapi
- name: Test lint
run: |
poetry run flake8 src/ecsapi
- name: Run tests
run: |
poetry run pytest --cov
build:
runs-on: ubuntu-22.04
needs:
- test
steps:
- uses: actions/checkout@v4
- id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: 'pip'
- name: Install Poetry
run: |
python3 -m pip install --upgrade pip
python3 -m pip install poetry
- name: Configure Poetry (in-project venv)
run: |
poetry config virtualenvs.in-project true
- name: Cache virtualenv
id: poetry-cache
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.poetry-cache.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-ansi
- name: Build package
run: |
poetry build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact
path: dist/
pypi-publish:
runs-on: ubuntu-22.04
needs:
- build
if: startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
environment:
name: pypi
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: build-artifact
path: dist/
- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/