-
Notifications
You must be signed in to change notification settings - Fork 323
218 lines (205 loc) · 6.6 KB
/
ci_pipeline.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: CI Pipeline
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
# Checks for changes in version.txt (used for release job)
changes:
runs-on: ubuntu-latest
outputs:
version_changed: ${{ steps.filter.outputs.version_changed }}
relevant_changes: ${{ steps.filter.outputs.relevant_changes }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
version_changed:
- 'cover_agent/version.txt'
relevant_changes:
- '!README.md'
- '!docs/**'
test:
needs: [changes]
if: needs.changes.outputs.relevant_changes == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Ensures we fetch all history for all branches
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.12'
# Step to cache Poetry dependencies
- name: Cache Poetry dependencies
uses: actions/cache@v2
with:
path: |
~/.cache/pypoetry
~/.cache/pip
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install Poetry
run: pip install poetry
- name: Install dependencies using Poetry
run: poetry install
- name: Run tests and generate reports
env:
OPENAI_API_KEY: "This_is_a_fake_API_key"
run: make test
- name: Upload test report
uses: actions/upload-artifact@v3
if: always()
with:
name: test-reports
path: testLog.xml
- name: Upload coverage report
uses: actions/upload-artifact@v3
if: always()
with:
name: coverage-reports
path: cobertura.xml
env:
pythonLocation: /opt/hostedtoolcache/Python/3.12.2/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.2/x64/lib
package-test:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.12'
# Step to cache Poetry dependencies
- name: Cache Poetry dependencies
uses: actions/cache@v2
with:
path: |
~/.cache/pypoetry
~/.cache/pip
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install Poetry
run: pip install poetry
- name: Install dependencies using Poetry
run: poetry install
- name: Build, Install and Test Package from Different Location
run: |
poetry build
pip install dist/*.whl
cd /tmp
cover-agent --help
build:
needs: [test, changes]
if: needs.changes.outputs.relevant_changes == 'true'
strategy:
matrix:
os: [ubuntu-22.04, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.12'
# Step to cache Poetry dependencies
- name: Cache Poetry dependencies
uses: actions/cache@v2
with:
path: |
~/.cache/pypoetry
~/.cache/pip
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install Dependencies
run: |
pip install poetry wandb tree_sitter
poetry install
- name: Build Executable
run: make installer
- name: Test Executable (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: .\dist\cover-agent.exe --help
shell: pwsh
- name: Test Executable (Unix)
if: ${{ matrix.os != 'windows-latest' }}
run: ./dist/cover-agent --help
shell: bash
- name: Upload Executable
uses: actions/upload-artifact@v3
with:
name: cover-agent-${{ matrix.os }}
path: dist/cover-agent*
release:
# This job will run only if the following conditions are met:
# - The event is a 'push' to the 'main' branch
# - The 'version.txt' file has changed
# - There are relevant changes outside of 'README.md' and the 'docs/' folder
needs: [build, changes]
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.changes.outputs.version_changed == 'true' && needs.changes.outputs.relevant_changes == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download executables (Ubuntu)
uses: actions/download-artifact@v3
with:
name: cover-agent-ubuntu-22.04
path: dist/ubuntu-22.04
- uses: actions/download-artifact@v3
with:
name: cover-agent-windows-latest
path: dist/windows-latest
- uses: actions/download-artifact@v3
with:
name: cover-agent-macos-latest
path: dist/macos-latest
- name: Extract version
run: |
echo "VERSION=$(cat cover_agent/version.txt)" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: Release ${{ env.VERSION }}
draft: false
prerelease: false
- name: Upload Release Asset (Ubuntu)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/ubuntu-22.04/cover-agent
asset_name: cover-agent-ubuntu
asset_content_type: application/octet-stream
- name: Upload Release Asset (Windows)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/windows-latest/cover-agent.exe
asset_name: cover-agent-windows.exe
asset_content_type: application/octet-stream
- name: Upload Release Asset (macOS)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/macos-latest/cover-agent
asset_name: cover-agent-macos
asset_content_type: application/octet-stream