⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 164 additions & 0 deletions .github/workflows/build_assets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
---
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI some of this file might be able to be axed due to codecov/codecov-cli#664

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good shout tyty

name: Build Compiled Assets

on:
workflow_call:
inputs:
release:
type: boolean
default: false
description: "Attach artifacts to a release"

jobs:
build_assets:
name: Build packages - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- os: macos-latest
TARGET: macos
# currently, wrapt pulls the arm64 version instead of the universal one, so the below is a hack
CMD_REQS: >
mkdir -p pip-packages && cd pip-packages && pip wheel --no-cache-dir --no-binary tree_sitter,ijson,charset_normalizer,PyYAML .. &&
rm $(ls | grep wrapt) && pip download wrapt --platform=universal2 --only-binary=:all: && pip install $(ls | grep wrapt) --force-reinstall && cd .. &&
pip install --no-deps --no-index --find-links=pip-packages pip-packages/*
CMD_BUILD: >
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|^./||'") &&
pyinstaller --add-binary ${STATICCODECOV_LIB_PATH}:. --copy-metadata codecov-cli --hidden-import staticcodecov_languages --target-arch universal2 -F codecov_cli/main.py &&
mv dist/main dist/codecovcli_macos &&
lipo -archs dist/codecovcli_macos | grep 'x86_64 arm64'
OUT_FILE_NAME: codecovcli_macos
ASSET_MIME: application/octet-stream

- os: ubuntu-22.04
TARGET: ubuntu
CMD_REQS: >
pip install -r requirements.txt && pip install .
CMD_BUILD: >
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|^./||'") &&
pyinstaller --add-binary ${STATICCODECOV_LIB_PATH}:. --copy-metadata codecov-cli --hidden-import staticcodecov_languages -F codecov_cli/main.py &&
cp ./dist/main ./dist/codecovcli_linux
OUT_FILE_NAME: codecovcli_linux
ASSET_MIME: application/octet-stream

- os: windows-latest
TARGET: windows
CMD_REQS: >
pip install -r requirements.txt && pip install .
CMD_BUILD: >
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 &&
Copy-Item -Path ".\dist\main.exe" -Destination ".\dist\codecovcli_windows.exe"
OUT_FILE_NAME: codecovcli_windows.exe
ASSET_MIME: application/vnd.microsoft.portable-executable

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"

- name: Install dependencies
run: |
cd codecov-cli
${{matrix.CMD_REQS}}
python setup.py build

- name: Install pyinstaller
run: pip install pyinstaller

- name: Build with pyinstaller for ${{matrix.TARGET}}
run: cd codecov-cli && ${{matrix.CMD_BUILD}}

- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
if: inputs.release == false
with:
name: ${{ matrix.OUT_FILE_NAME }}
path: ./codecov-cli/dist/${{ matrix.OUT_FILE_NAME }}

- name: Get auth token
if: inputs.release == true
id: token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}

- name: Upload Release Asset
if: inputs.release == true
id: upload-release-asset
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ steps.token.outputs.token }}
file: ./codecov-cli/dist/${{ matrix.OUT_FILE_NAME }}
asset_name: ${{ matrix.OUT_FILE_NAME }}
tag: ${{ github.ref }}
overwrite: true

build_assets_alpine_arm:
name: Build assets - Alpine and ARM
runs-on: ubuntu-latest
strategy:
matrix:
include:
- distro: "python:3.11-alpine3.18"
arch: arm64
distro_name: alpine
- distro: "python:3.11-alpine3.18"
arch: x86_64
distro_name: alpine
- distro: "python:3.11-bullseye"
arch: arm64
distro_name: linux

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: ${{ matrix.arch }}

- name: Run in Docker
run: |
docker run \
--rm \
-v $(pwd):/${{ github.workspace }} \
-w ${{ github.workspace }} \
--platform linux/${{ matrix.arch }} \
${{ matrix.distro }} \
./codecov-cli/scripts/build_${{ matrix.distro_name }}_arm.sh ${{ matrix.distro_name }}_${{ matrix.arch }}

- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
if: inputs.release == false
with:
name: codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
path: ./codecov-cli/dist/codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}

- name: Get auth token
if: inputs.release == true
id: token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}

- name: Upload Release Asset
if: inputs.release == true
id: upload-release-asset
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ steps.token.outputs.token }}
file: ./codecov-cli/dist/codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
asset_name: codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
tag: ${{ github.ref }}
overwrite: true
71 changes: 71 additions & 0 deletions .github/workflows/build_for_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: Build for PyPi

on:
workflow_call:
inputs:
publish:
type: boolean
default: false
description: "Build for PyPi"

jobs:
build_src_for_pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
submodules: true

- name: Install dependencies
run: |
pip install build

- name: Build src dist
run: |
cd codecov-cli
python -m build --sdist
env:
PIP_CONSTRAINT: requirements.txt

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: ./**/*.tar.gz

build_dist_for_pypi:
needs:
- build_src_for_pypi
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-13
- macos-latest
- ubuntu-24.04-arm
- ubuntu-latest
- windows-latest
steps:
- name: Download the sdist
uses: actions/download-artifact@v4
with:
name: cibw-sdist

- name: Get sdist filename
id: get-sdist
run: |
echo "sdist_filename=$(ls codecov-cli/dist/)" >> "${GITHUB_OUTPUT}"
shell: bash

- name: Build wheels
uses: pypa/[email protected]
with:
package-dir: codecov-cli/dist/${{ steps.get-sdist.outputs.sdist_filename }}

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl
6 changes: 3 additions & 3 deletions .github/workflows/ci-job.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: CLI CI Job

on:
Expand All @@ -17,17 +14,20 @@ jobs:
with:
submodules: true
fetch-depth: 2

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
cd codecov-cli
python -m pip install --upgrade pip
pip install -r requirements.txt
python -m pip install -e .
pip install -r tests/requirements.txt

- name: Test with pytest
run: |
cd codecov-cli
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true

- name: Check linting with ruff
run: |
make lint
Expand All @@ -28,18 +29,22 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e codecov-cli
python -m pip install -e prevent-cli

- name: Run command_dump
run: |
./command_dump.py

- name: Detect changes on commit
run: |
if [ -n "$(git diff codecov-cli/codecovcli_commands prevent-cli/preventcli_commands)" ]; then
Expand All @@ -56,16 +61,20 @@ jobs:
with:
submodules: true
fetch-depth: 2

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install CLI
# todo: update this to dogfood prevent cli, maybe try both?
run: |
pip install codecov-cli

- name: Create commit in codecov
run: |
codecovcli create-commit -t ${{ secrets.CODECOV_TOKEN }} --git-service github

- name: Create commit report in codecov
run: |
codecovcli create-report -t ${{ secrets.CODECOV_TOKEN }} --git-service github
Expand All @@ -82,27 +91,32 @@ jobs:
with:
submodules: true
fetch-depth: 2

- name: Set up Python ${{matrix.python-version}}
uses: actions/setup-python@v5
with:
python-version: "${{matrix.python-version}}"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e codecov-cli
python -m pip install -e prevent-cli
pip install -r codecov-cli/tests/requirements.txt

- name: Test with pytest
run: |
cd codecov-cli
pytest --cov --junitxml=${{matrix.os}}-${{matrix.python-version}}junit.xml
env:
CODECOV_ENV: test

- name: Dogfooding codecov-cli
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'getsentry' }}
run: |
codecovcli -v do-upload --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} --flag codecovcli
codecovcli do-upload --report-type test_results --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} --flag codecovcli

- name: Dogfooding sentry-prevent-cli
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'getsentry' }}
run: |
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Create CLI Release

on:
pull_request:
branches:
- main
types: [closed]

jobs:
create-release:
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') && github.repository_owner == 'getsentry' }}
name: Create Github Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- id: get-release-vars
name: Configure Release Vars
run: |
release_version=v$(grep -E "version = \"[0-9]+\.[0-9]+\.[0-9]+\"" pyproject.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")
previous_version=$(git tag --sort=-creatordate | head -n 2 | tail -n 1)
echo "release_version=$release_version"
echo "previous_version=$previous_version"

echo "release_version=$release_version" >> "$GITHUB_OUTPUT"
echo "previous_version=$previous_version" >> "$GITHUB_OUTPUT"

- name: Get auth token
id: token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}

# todo: potentially switch to https://github.com/getsentry/action-prepare-release once set up with craft
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
run: |
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 }}
Loading