-
Notifications
You must be signed in to change notification settings - Fork 0
172 lines (163 loc) · 5.53 KB
/
ci.yaml
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
name: Pipeline
on:
push: ~
pull_request: ~
workflow_dispatch:
env:
PYTHON_VERSION: 3.11
jobs:
validate-pipeline:
uses: armakuni/github-actions/.github/workflows/lint-pipeline.yml@v0.16.8
validate-action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
max_carbon_intensity: 10000
validate-python:
defaults:
run:
shell: bash
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: specdown/setup-specdown-action@v0.2.22
- name: Set up python ${{ env.PYTHON_VERSION }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Load cached Poetry Binary
id: cached-poetry-binary
uses: actions/cache@v3
with:
path: ~/.local
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
- run: curl -sSL https://install.python-poetry.org | python3 -
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
shell: bash
run: poetry install --no-interaction --no-root
- run: make lint
- run: make test
- run: |
echo "$CO2_SIGNAL_API_KEY" > .co2_api_key
make integration
env:
CO2_SIGNAL_API_KEY: ${{secrets.CO2_SIGNAL_API_KEY}}
if: github.ref == 'refs/heads/main'
- name: Spot vunerable dependencies
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
exit-code: '1'
scan-ref: .
all-tests-succeeded:
needs: [ validate-pipeline, validate-action, validate-python ]
runs-on: ubuntu-latest
steps:
- run: echo "All tests succeeded"
release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: [ all-tests-succeeded ]
name: Release
permissions:
contents: write
outputs:
version: ${{ steps.release.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up python ${{ env.PYTHON_VERSION }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Load cached Poetry Binary
id: cached-poetry-binary
uses: actions/cache@v3
with:
path: ~/.local
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
- run: curl -sSL https://install.python-poetry.org | python3 -
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
shell: bash
run: poetry install --no-interaction --no-root
- name: Cocogitto release
id: release
continue-on-error: true
uses: oknozor/cocogitto-action@v3.5
with:
release: true
- name: Generate Changelog
if: steps.release.outputs.version != ''
run: cog changelog --at ${{ steps.release.outputs.version }} -t full_hash > GITHUB_CHANGELOG.md
- name: Upload github release
if: steps.release.outputs.version != ''
uses: softprops/action-gh-release@v1
with:
body_path: GITHUB_CHANGELOG.md
tag_name: ${{ steps.release.outputs.version }}
pypi-publish:
needs: [ release ]
name: Upload release to PyPI
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.version }}
- name: Set up python ${{ env.PYTHON_VERSION }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Load cached Poetry Binary
id: cached-poetry-binary
uses: actions/cache@v3
with:
path: ~/.local
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
- run: curl -sSL https://install.python-poetry.org | python3 -
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
shell: bash
run: poetry install --no-interaction --no-root
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
shell: bash
run: poetry build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true