Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/urllib3-2.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrockhu-codecov authored Dec 4, 2024
2 parents 33a163c + ceeaddc commit bbef4ae
Show file tree
Hide file tree
Showing 121 changed files with 4,804 additions and 932 deletions.
57 changes: 51 additions & 6 deletions .github/workflows/build_assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ jobs:
matrix:
include:
- os: macos-latest
env:
CFLAGS: -arch arm64 -arch x86_64
TARGET: macos
CMD_REQS: >
mkdir -p pip-packages && cd pip-packages && pip wheel --no-cache-dir --no-binary tree_sitter,ijson,charset_normalizer,PyYAML .. && cd .. &&
Expand All @@ -33,8 +31,7 @@ jobs:
- os: ubuntu-20.04
TARGET: ubuntu
CMD_REQS: >
pip install -r requirements.txt
pip install .
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 &&
Expand All @@ -44,8 +41,7 @@ jobs:
- os: windows-latest
TARGET: windows
CMD_REQS: >
pip install -r requirements.txt
pip install .
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"
Expand Down Expand Up @@ -83,5 +79,54 @@ jobs:
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 }} \
./scripts/build_${{ matrix.distro_name }}_arm.sh ${{ matrix.distro_name }}_${{ matrix.arch }}
- name: Upload a Build Artifact
uses: actions/[email protected]
if: inputs.release == false
with:
path: ./dist/codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
- name: Upload Release Asset
if: inputs.release == true
id: upload-release-asset
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./dist/codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
asset_name: codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
tag: ${{ github.ref }}
overwrite: true



6 changes: 3 additions & 3 deletions .github/workflows/build_for_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ jobs:
- name: Publish package to PyPi
if: inputs.publish == true
uses: pypa/gh-action-pypi-publish@release/v1



with:
attestations: false
verbose: true
41 changes: 41 additions & 0 deletions .github/workflows/ci-job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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:
pull_request:
push:
branches:
- main

jobs:
build-test-upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
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: |
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: |
pytest --cov --junitxml=3.12junit.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: python3.12
fail_ci_if_error: true
verbose: true
83 changes: 63 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,22 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies
- name: Check linting with ruff
run: |
python -m pip install --upgrade pip
pip install black==22.3.0 isort==5.10.1
- name: Check linting with black
run: |
black --check codecov_cli
- name: Check imports order with isort
run: |
isort --check --profile=black codecov_cli -p staticcodecov_languages
make lint
codecov-startup:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 2
- uses: actions/setup-python@v3
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install CLI
run: |
pip install codecov-cli
Expand All @@ -47,11 +44,11 @@ jobs:
build-test-upload:
runs-on: ubuntu-latest
needs: codecov-startup
strategy:
fail-fast: false
matrix:
include:
- python-version: "3.12"
- python-version: "3.11"
- python-version: "3.10"
- python-version: "3.9"
Expand All @@ -62,31 +59,42 @@ jobs:
submodules: true
fetch-depth: 2
- name: Set up Python ${{matrix.python-version}}
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: "${{matrix.python-version}}"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py develop
python -m pip install -e .
pip install -r tests/requirements.txt
- name: Test with pytest
run: |
pytest --cov
pytest --cov --junitxml=${{matrix.python-version}}junit.xml
- name: Dogfooding codecov-cli
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli do-upload --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}}
codecovcli -v do-upload --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}}
codecovcli do-upload --report-type test_results --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}}
- name: Upload artifacts for test-results-processing
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: ${{matrix.python-version}}junit.xml
path: ${{matrix.python-version}}junit.xml

static-analysis:
runs-on: ubuntu-latest
needs: codecov-startup
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 2
- uses: actions/setup-python@v3
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install CLI
run: |
pip install codecov-cli
Expand All @@ -101,16 +109,21 @@ jobs:
label-analysis:
runs-on: ubuntu-latest
needs: static-analysis
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-python@v3
- name: Install CLI
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies for Dogfooding
run: |
pip install -r requirements.txt -r tests/requirements.txt
pip install 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: Label Analysis
run: |
BASE_SHA=$(git merge-base HEAD^ origin/main)
Expand All @@ -119,3 +132,33 @@ jobs:
- name: Upload smart-labels
run: |
codecovcli --codecov-yml-path=codecov.yml do-upload --plugin pycoverage --plugin compress-pycoverage --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --flag smart-labels
process-test-results:
if: ${{ always() }}
needs: build-test-upload
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 2
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies for Dogfooding
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python -m pip install -e .
pip install -r tests/requirements.txt
- name: Download all test results
uses: actions/download-artifact@v4
with:
pattern: "*junit.xml"
path: "test_results"
merge-multiple: true

- name: Dogfooding codecov-cli
if: ${{ !cancelled() && github.ref && contains(github.ref, 'pull') }}
run: |
codecovcli process-test-results --dir test_results --github-token ${{ secrets.GITHUB_TOKEN }}
15 changes: 5 additions & 10 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ on:
jobs:
create-release:
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') && github.repository_owner == 'codecov' }}
env:
GITHUB_TOKEN: ${{ secrets.CODECOV_RELEASE_PAT }}
name: Create Github Release
runs-on: ubuntu-latest
steps:
Expand All @@ -22,11 +20,8 @@ jobs:
run: |
echo release_version=$(grep -E "version=\"[0-9]\.[0-9]\.[0-9]\"" setup.py | grep -Eo "[0-9]\.[0-9]\.[0-9]") >> "$GITHUB_OUTPUT"
- name: Create GH Release
uses: softprops/[email protected]
with:
name: Release v${{ steps.get-release-vars.outputs.release_version }}
tag_name: v${{ steps.get-release-vars.outputs.release_version }}
generate_release_notes: true
body: Autogenerated for ${{ steps.get-release-vars.outputs.release_version }}. Created for ${{ github.event.pull_request.html_url }}

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.CODECOV_RELEASE_PAT }}
run: |
gh release create v${{ steps.get-release-vars.outputs.release_version }} --title "Release v${{ steps.get-release-vars.outputs.release_version }}" --notes "Autogenerated for v${{ steps.get-release-vars.outputs.release_version }}. Created for ${{ github.event.pull_request.html_url }}" --generate-notes --target ${{ github.event.pull_request.head.sha }}
14 changes: 14 additions & 0 deletions .github/workflows/enforce-license-compliance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Enforce License Compliance

on:
pull_request:
branches: [main, master]

jobs:
enforce-license-compliance:
runs-on: ubuntu-latest
steps:
- name: 'Enforce License Compliance'
uses: getsentry/action-enforce-license-compliance@57ba820387a1a9315a46115ee276b2968da51f3d # main
with:
fossa_api_key: ${{ secrets.FOSSA_API_KEY }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,5 @@ cython_debug/
# Vim temporary files
*.swp
*.swo

.debug
26 changes: 20 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@ name ?= codecovcli
# Semantic versioning format https://semver.org/
tag_regex := ^v([0-9]{1,}\.){2}[0-9]{1,}([-_]\w+)?$

lint.install:
echo "Installing ruff..."
pip install -Iv ruff

# The preferred method (for now) w.r.t. fixable rules is to manually update the makefile
# with --fix and re-run 'make lint.' Since ruff is constantly adding rules this is a slight
# amount of "needed" friction imo.
lint.run:
ruff check --ignore F401 --exclude languages --exclude samples
ruff format --exclude languages --exclude samples

lint.check:
echo "Linting..."
ruff check --ignore F401 --exclude languages --exclude samples
echo "Formatting..."
ruff format --check --exclude languages --exclude samples

lint:
pip install black==22.3.0 isort==5.10.1
black codecov_cli
isort --profile=black codecov_cli -p staticcodecov_languages
black tests
isort --profile black tests
make lint.install
make lint.run

tag.release:
ifeq ($(shell echo ${version} | egrep "${tag_regex}"),)
Expand All @@ -16,4 +30,4 @@ else
@echo "Tagging new release ${version}"
git tag -a ${version} -m "Autogenerated release tag for codecov-cli"
git push origin ${version}
endif
endif
Loading

0 comments on commit bbef4ae

Please sign in to comment.