From c94c6364bb0b0daa52804eedaac97d7e06925a1e Mon Sep 17 00:00:00 2001 From: qdelamea Date: Tue, 15 Oct 2024 17:35:59 +0200 Subject: [PATCH] ci: add code integration workflow --- .github/workflows/ci.yml | 92 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0a31549 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,92 @@ +name: Code Integration + +on: + push: + pull_request: + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + code-quality: + name: Check linting, formatting and typing + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Install dependencies + run: | + python -m pip install uv + python -m uv pip install .[dev] + + - name: Lintting + run: python -m ruff check . + + - name: Type checking + run: python -m mypy . + + - name: Formatting + run: python -m ruff format . + + - name: Check Diff + run: | + DIFF="$(git diff --name-only)" + + if [ -z "$DIFF" ]; then + echo "OK: Format is clean" + else + echo "Error: Format was not clean" + echo "List of files:" + echo "$DIFF" + git diff + exit 1 + fi + + testing: + name: Test Python Package + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Install dependencies + run: | + python -m pip install uv + python -m uv pip install .[tests] + + - name: Testing + run: pytest tests --cov=armonik_cli --cov-report=term-missing + + - name: Get Report + uses: orgoro/coverage@3f13a558c5af7376496aa4848bf0224aead366ac + with: + coverageFile: packages/python/coverage.xml + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Archive code coverage results html + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a + with: + name: code-coverage-report-html + path: packages/python/coverage_report + + - name: Archive code coverage results xml + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a + with: + name: code-coverage-report-xml + path: packages/python/coverage.xml