-
Notifications
You must be signed in to change notification settings - Fork 376
135 lines (130 loc) · 4.4 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
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 }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
version_changed:
- 'cover_agent/version.txt'
test:
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.x'
- 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: |
poetry run pytest --junitxml=testLog.xml --cov=templated_tests --cov=cover_agent --cov-report=xml:cobertura.xml --cov-report=term --cov-fail-under=70 --log-cli-level=INFO
- name: Upload test report
uses: actions/upload-artifact@v2
if: always()
with:
name: test-reports
path: testLog.xml
- name: Upload coverage report
uses: actions/upload-artifact@v2
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
build:
needs: test
strategy:
matrix:
os: [ubuntu-latest, 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.x'
- name: Install Dependencies
run: |
pip install poetry
poetry install
- name: Build Executable
run: |
poetry run pyinstaller --add-data "cover_agent/prompt_template.md:." --add-data "cover_agent/version.txt:." --hidden-import=tiktoken_ext.openai_public --hidden-import=tiktoken_ext --onefile --name cover-agent-${{ matrix.os }} cover_agent/main.py
- name: Upload Executable
uses: actions/upload-artifact@v2
with:
name: cover-agent-${{ matrix.os }}
path: dist/cover-agent-${{ matrix.os }}*
release:
needs: [build, changes]
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.changes.outputs.version_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download executables
uses: actions/download-artifact@v2
with:
path: dist
- 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/cover-agent-ubuntu-latest/cover-agent-ubuntu-latest
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/cover-agent-windows-latest/cover-agent-windows-latest.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/cover-agent-macos-latest/cover-agent-macos-latest
asset_name: cover-agent-macos
asset_content_type: application/octet-stream