Skip to content

Commit ac6a04a

Browse files
authored
Merge pull request #8 from getsentry/spalmurray/remaining-workflows-for-cccli
feat: Update build/release workflows
2 parents 9e55f61 + 456a3df commit ac6a04a

9 files changed

Lines changed: 429 additions & 3 deletions

File tree

.github/workflows/build_assets.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
name: Build Compiled Assets
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
release:
8+
type: boolean
9+
default: false
10+
description: "Attach artifacts to a release"
11+
12+
jobs:
13+
build_assets:
14+
name: Build packages - ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: true
18+
matrix:
19+
include:
20+
- os: macos-latest
21+
TARGET: macos
22+
# currently, wrapt pulls the arm64 version instead of the universal one, so the below is a hack
23+
CMD_REQS: >
24+
mkdir -p pip-packages && cd pip-packages && pip wheel --no-cache-dir --no-binary tree_sitter,ijson,charset_normalizer,PyYAML .. &&
25+
rm $(ls | grep wrapt) && pip download wrapt --platform=universal2 --only-binary=:all: && pip install $(ls | grep wrapt) --force-reinstall && cd .. &&
26+
pip install --no-deps --no-index --find-links=pip-packages pip-packages/*
27+
CMD_BUILD: >
28+
STATICCODECOV_LIB_PATH=$(find build/ -maxdepth 1 -type d -name 'lib.*' -print -quit | xargs -I {} sh -c "find {} -type f -name 'staticcodecov*' -print -quit | sed 's|^./||'") &&
29+
pyinstaller --add-binary ${STATICCODECOV_LIB_PATH}:. --copy-metadata codecov-cli --hidden-import staticcodecov_languages --target-arch universal2 -F codecov_cli/main.py &&
30+
mv dist/main dist/codecovcli_macos &&
31+
lipo -archs dist/codecovcli_macos | grep 'x86_64 arm64'
32+
OUT_FILE_NAME: codecovcli_macos
33+
ASSET_MIME: application/octet-stream
34+
35+
- os: ubuntu-22.04
36+
TARGET: ubuntu
37+
CMD_REQS: >
38+
pip install -r requirements.txt && pip install .
39+
CMD_BUILD: >
40+
STATICCODECOV_LIB_PATH=$(find build/ -maxdepth 1 -type d -name 'lib.*' -print -quit | xargs -I {} sh -c "find {} -type f -name 'staticcodecov*' -print -quit | sed 's|^./||'") &&
41+
pyinstaller --add-binary ${STATICCODECOV_LIB_PATH}:. --copy-metadata codecov-cli --hidden-import staticcodecov_languages -F codecov_cli/main.py &&
42+
cp ./dist/main ./dist/codecovcli_linux
43+
OUT_FILE_NAME: codecovcli_linux
44+
ASSET_MIME: application/octet-stream
45+
46+
- os: windows-latest
47+
TARGET: windows
48+
CMD_REQS: >
49+
pip install -r requirements.txt && pip install .
50+
CMD_BUILD: >
51+
pyinstaller --add-binary "build\lib.win-amd64-cpython-311\staticcodecov_languages.cp311-win_amd64.pyd;." --copy-metadata codecov-cli --hidden-import staticcodecov_languages -F codecov_cli\main.py &&
52+
Copy-Item -Path ".\dist\main.exe" -Destination ".\dist\codecovcli_windows.exe"
53+
OUT_FILE_NAME: codecovcli_windows.exe
54+
ASSET_MIME: application/vnd.microsoft.portable-executable
55+
56+
steps:
57+
- uses: actions/checkout@v4
58+
with:
59+
submodules: true
60+
61+
- name: Set up Python 3.11
62+
uses: actions/setup-python@v3
63+
with:
64+
python-version: "3.11"
65+
66+
- name: Install dependencies
67+
run: |
68+
cd codecov-cli
69+
${{matrix.CMD_REQS}}
70+
python setup.py build
71+
72+
- name: Install pyinstaller
73+
run: pip install pyinstaller
74+
75+
- name: Build with pyinstaller for ${{matrix.TARGET}}
76+
run: cd codecov-cli && ${{matrix.CMD_BUILD}}
77+
78+
- name: Upload a Build Artifact
79+
uses: actions/upload-artifact@v4
80+
if: inputs.release == false
81+
with:
82+
name: ${{ matrix.OUT_FILE_NAME }}
83+
path: ./codecov-cli/dist/${{ matrix.OUT_FILE_NAME }}
84+
85+
- name: Get auth token
86+
if: inputs.release == true
87+
id: token
88+
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
89+
with:
90+
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
91+
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
92+
93+
- name: Upload Release Asset
94+
if: inputs.release == true
95+
id: upload-release-asset
96+
uses: svenstaro/upload-release-action@v2
97+
with:
98+
repo_token: ${{ steps.token.outputs.token }}
99+
file: ./codecov-cli/dist/${{ matrix.OUT_FILE_NAME }}
100+
asset_name: ${{ matrix.OUT_FILE_NAME }}
101+
tag: ${{ github.ref }}
102+
overwrite: true
103+
104+
build_assets_alpine_arm:
105+
name: Build assets - Alpine and ARM
106+
runs-on: ubuntu-latest
107+
strategy:
108+
matrix:
109+
include:
110+
- distro: "python:3.11-alpine3.18"
111+
arch: arm64
112+
distro_name: alpine
113+
- distro: "python:3.11-alpine3.18"
114+
arch: x86_64
115+
distro_name: alpine
116+
- distro: "python:3.11-bullseye"
117+
arch: arm64
118+
distro_name: linux
119+
120+
steps:
121+
- uses: actions/checkout@v4
122+
with:
123+
submodules: true
124+
125+
- name: Set up QEMU
126+
uses: docker/setup-qemu-action@v1
127+
with:
128+
platforms: ${{ matrix.arch }}
129+
130+
- name: Run in Docker
131+
run: |
132+
docker run \
133+
--rm \
134+
-v $(pwd):/${{ github.workspace }} \
135+
-w ${{ github.workspace }} \
136+
--platform linux/${{ matrix.arch }} \
137+
${{ matrix.distro }} \
138+
./codecov-cli/scripts/build_${{ matrix.distro_name }}_arm.sh ${{ matrix.distro_name }}_${{ matrix.arch }}
139+
140+
- name: Upload a Build Artifact
141+
uses: actions/upload-artifact@v4
142+
if: inputs.release == false
143+
with:
144+
name: codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
145+
path: ./codecov-cli/dist/codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
146+
147+
- name: Get auth token
148+
if: inputs.release == true
149+
id: token
150+
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
151+
with:
152+
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
153+
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
154+
155+
- name: Upload Release Asset
156+
if: inputs.release == true
157+
id: upload-release-asset
158+
uses: svenstaro/upload-release-action@v2
159+
with:
160+
repo_token: ${{ steps.token.outputs.token }}
161+
file: ./codecov-cli/dist/codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
162+
asset_name: codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
163+
tag: ${{ github.ref }}
164+
overwrite: true
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
name: Build for PyPi
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
publish:
8+
type: boolean
9+
default: false
10+
description: "Build for PyPi"
11+
12+
jobs:
13+
build_src_for_pypi:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
persist-credentials: false
19+
submodules: true
20+
21+
- name: Install dependencies
22+
run: |
23+
pip install build
24+
25+
- name: Build src dist
26+
run: |
27+
cd codecov-cli
28+
python -m build --sdist
29+
env:
30+
PIP_CONSTRAINT: requirements.txt
31+
32+
- name: Store the distribution packages
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: cibw-sdist
36+
path: ./**/*.tar.gz
37+
38+
build_dist_for_pypi:
39+
needs:
40+
- build_src_for_pypi
41+
runs-on: ${{ matrix.os }}
42+
strategy:
43+
matrix:
44+
os:
45+
- macos-13
46+
- macos-latest
47+
- ubuntu-24.04-arm
48+
- ubuntu-latest
49+
- windows-latest
50+
steps:
51+
- name: Download the sdist
52+
uses: actions/download-artifact@v4
53+
with:
54+
name: cibw-sdist
55+
56+
- name: Get sdist filename
57+
id: get-sdist
58+
run: |
59+
echo "sdist_filename=$(ls codecov-cli/dist/)" >> "${GITHUB_OUTPUT}"
60+
shell: bash
61+
62+
- name: Build wheels
63+
uses: pypa/cibuildwheel@v2.22.0
64+
with:
65+
package-dir: codecov-cli/dist/${{ steps.get-sdist.outputs.sdist_filename }}
66+
67+
- name: Store the distribution packages
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: cibw-wheels-${{ matrix.os }}
71+
path: ./wheelhouse/*.whl

.github/workflows/ci-job.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
41
name: CLI CI Job
52

63
on:
@@ -17,17 +14,20 @@ jobs:
1714
with:
1815
submodules: true
1916
fetch-depth: 2
17+
2018
- name: Set up Python 3.12
2119
uses: actions/setup-python@v5
2220
with:
2321
python-version: "3.12"
22+
2423
- name: Install dependencies
2524
run: |
2625
cd codecov-cli
2726
python -m pip install --upgrade pip
2827
pip install -r requirements.txt
2928
python -m pip install -e .
3029
pip install -r tests/requirements.txt
30+
3131
- name: Test with pytest
3232
run: |
3333
cd codecov-cli

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- uses: actions/checkout@v4
1919
with:
2020
submodules: true
21+
2122
- name: Check linting with ruff
2223
run: |
2324
make lint
@@ -28,18 +29,22 @@ jobs:
2829
- uses: actions/checkout@v4
2930
with:
3031
submodules: true
32+
3133
- name: Set up Python 3.12
3234
uses: actions/setup-python@v5
3335
with:
3436
python-version: "3.12"
37+
3538
- name: Install dependencies
3639
run: |
3740
python -m pip install --upgrade pip
3841
python -m pip install -e codecov-cli
3942
python -m pip install -e prevent-cli
43+
4044
- name: Run command_dump
4145
run: |
4246
./command_dump.py
47+
4348
- name: Detect changes on commit
4449
run: |
4550
if [ -n "$(git diff codecov-cli/codecovcli_commands prevent-cli/preventcli_commands)" ]; then
@@ -56,16 +61,20 @@ jobs:
5661
with:
5762
submodules: true
5863
fetch-depth: 2
64+
5965
- uses: actions/setup-python@v5
6066
with:
6167
python-version: "3.12"
68+
6269
- name: Install CLI
6370
# todo: update this to dogfood prevent cli, maybe try both?
6471
run: |
6572
pip install codecov-cli
73+
6674
- name: Create commit in codecov
6775
run: |
6876
codecovcli create-commit -t ${{ secrets.CODECOV_TOKEN }} --git-service github
77+
6978
- name: Create commit report in codecov
7079
run: |
7180
codecovcli create-report -t ${{ secrets.CODECOV_TOKEN }} --git-service github
@@ -82,27 +91,32 @@ jobs:
8291
with:
8392
submodules: true
8493
fetch-depth: 2
94+
8595
- name: Set up Python ${{matrix.python-version}}
8696
uses: actions/setup-python@v5
8797
with:
8898
python-version: "${{matrix.python-version}}"
99+
89100
- name: Install dependencies
90101
run: |
91102
python -m pip install --upgrade pip
92103
python -m pip install -e codecov-cli
93104
python -m pip install -e prevent-cli
94105
pip install -r codecov-cli/tests/requirements.txt
106+
95107
- name: Test with pytest
96108
run: |
97109
cd codecov-cli
98110
pytest --cov --junitxml=${{matrix.os}}-${{matrix.python-version}}junit.xml
99111
env:
100112
CODECOV_ENV: test
113+
101114
- name: Dogfooding codecov-cli
102115
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'getsentry' }}
103116
run: |
104117
codecovcli -v do-upload --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} --flag codecovcli
105118
codecovcli do-upload --report-type test_results --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} --flag codecovcli
119+
106120
- name: Dogfooding sentry-prevent-cli
107121
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'getsentry' }}
108122
run: |
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Create CLI Release
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types: [closed]
8+
9+
jobs:
10+
create-release:
11+
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') && github.repository_owner == 'getsentry' }}
12+
name: Create Github Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
fetch-tags: true
20+
21+
- id: get-release-vars
22+
name: Configure Release Vars
23+
run: |
24+
release_version=v$(grep -E "version = \"[0-9]+\.[0-9]+\.[0-9]+\"" pyproject.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")
25+
previous_version=$(git tag --sort=-creatordate | head -n 2 | tail -n 1)
26+
echo "release_version=$release_version"
27+
echo "previous_version=$previous_version"
28+
29+
echo "release_version=$release_version" >> "$GITHUB_OUTPUT"
30+
echo "previous_version=$previous_version" >> "$GITHUB_OUTPUT"
31+
32+
- name: Get auth token
33+
id: token
34+
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
35+
with:
36+
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
37+
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
38+
39+
# todo: potentially switch to https://github.com/getsentry/action-prepare-release once set up with craft
40+
- name: Create GitHub Release
41+
env:
42+
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
43+
run: |
44+
gh release create ${{ steps.get-release-vars.outputs.release_version }} --title "Release ${{ steps.get-release-vars.outputs.release_version }}" --notes "Autogenerated for ${{ steps.get-release-vars.outputs.release_version }}. Created for ${{ github.event.pull_request.html_url }}" --generate-notes --notes-start-tag ${{steps.get-release-vars.outputs.previous_version}} --target ${{ github.event.pull_request.head.sha }}

0 commit comments

Comments
 (0)