Skip to content

Commit 5fec27f

Browse files
authored
Create ci_pipeline.yml
1 parent b146a19 commit 5fec27f

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed

.github/workflows/ci_pipeline.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: CI Pipeline
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
# Validate that the version.txt file was incremented to ensure release process passes after merge to main
13+
check_version_increment:
14+
runs-on: ubuntu-latest
15+
# This job will only run for pull requests, not for pushes to main
16+
if: github.event_name == 'pull_request'
17+
steps:
18+
- uses: actions/checkout@v2
19+
with:
20+
fetch-depth: 0 # Ensures we fetch all history for all branches
21+
- name: Check if version was incremented
22+
run: |
23+
NEW_VERSION=$(cat cover_agent/version.txt)
24+
git fetch origin main
25+
git checkout origin/main -- cover_agent/version.txt
26+
OLD_VERSION=$(cat cover_agent/version.txt)
27+
if [[ "$OLD_VERSION" == "$NEW_VERSION" ]]; then
28+
echo "ERROR: The version number in version.txt must be incremented."
29+
echo "Version on origin/main: $OLD_VERSION"
30+
echo "Version on ${{ github.head_ref }}: $NEW_VERSION"
31+
exit 1
32+
fi
33+
34+
test:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v2
38+
with:
39+
fetch-depth: 0 # Ensures we fetch all history for all branches
40+
- name: Set up Python
41+
uses: actions/setup-python@v2
42+
with:
43+
python-version: '3.x'
44+
- name: Install Poetry
45+
run: pip install poetry
46+
- name: Install dependencies using Poetry
47+
run: poetry install
48+
- name: Run tests and generate reports
49+
env:
50+
OPENAI_API_KEY: "This_is_a_fake_API_key"
51+
run: |
52+
poetry run pytest --junitxml=testLog.xml --cov=templated_tests --cov=cover_agent --cov-report=xml:cobertura.xml --log-cli-level=INFO
53+
- name: Upload test report
54+
uses: actions/upload-artifact@v2
55+
if: always()
56+
with:
57+
name: test-reports
58+
path: testLog.xml
59+
- name: Upload coverage report
60+
uses: actions/upload-artifact@v2
61+
if: always()
62+
with:
63+
name: coverage-reports
64+
path: cobertura.xml
65+
- name: Cobertura Coverage Report
66+
uses: 5monkeys/cobertura-action@master
67+
with:
68+
path: cobertura.xml
69+
repo_token: ${{ secrets.GITHUB_TOKEN }}
70+
minimum_coverage: 60
71+
env:
72+
pythonLocation: /opt/hostedtoolcache/Python/3.12.2/x64
73+
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.2/x64/lib
74+
75+
build:
76+
needs: test
77+
strategy:
78+
matrix:
79+
os: [ubuntu-latest, windows-latest, macos-latest]
80+
runs-on: ${{ matrix.os }}
81+
steps:
82+
- uses: actions/checkout@v2
83+
- name: Set up Python
84+
uses: actions/setup-python@v2
85+
with:
86+
python-version: '3.x'
87+
- name: Install Dependencies
88+
run: |
89+
pip install poetry
90+
poetry install
91+
- name: Build Executable
92+
run: |
93+
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
94+
- name: Upload Executable
95+
uses: actions/upload-artifact@v2
96+
with:
97+
name: cover-agent-${{ matrix.os }}
98+
path: dist/cover-agent-${{ matrix.os }}*
99+
100+
release:
101+
needs: build
102+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
103+
runs-on: ubuntu-latest
104+
steps:
105+
- uses: actions/checkout@v2
106+
- name: Download executables
107+
uses: actions/download-artifact@v2
108+
with:
109+
path: dist
110+
- name: Extract version
111+
run: |
112+
echo "VERSION=$(cat cover_agent/version.txt)" >> $GITHUB_ENV
113+
- name: Create Release
114+
id: create_release
115+
uses: actions/create-release@v1
116+
env:
117+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118+
with:
119+
tag_name: ${{ env.VERSION }}
120+
release_name: Release ${{ env.VERSION }}
121+
draft: false
122+
prerelease: false
123+
- name: Upload Release Asset (Ubuntu)
124+
uses: actions/upload-release-asset@v1
125+
env:
126+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+
with:
128+
upload_url: ${{ steps.create_release.outputs.upload_url }}
129+
asset_path: ./dist/cover-agent-ubuntu-latest/cover-agent-ubuntu-latest
130+
asset_name: cover-agent-ubuntu
131+
asset_content_type: application/octet-stream
132+
- name: Upload Release Asset (Windows)
133+
uses: actions/upload-release-asset@v1
134+
env:
135+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136+
with:
137+
upload_url: ${{ steps.create_release.outputs.upload_url }}
138+
asset_path: ./dist/cover-agent-windows-latest/cover-agent-windows-latest.exe
139+
asset_name: cover-agent-windows.exe
140+
asset_content_type: application/octet-stream
141+
- name: Upload Release Asset (macOS)
142+
uses: actions/upload-release-asset@v1
143+
env:
144+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145+
with:
146+
upload_url: ${{ steps.create_release.outputs.upload_url }}
147+
asset_path: ./dist/cover-agent-macos-latest/cover-agent-macos-latest
148+
asset_name: cover-agent-macos
149+
asset_content_type: application/octet-stream

0 commit comments

Comments
 (0)