From c8771b2e9dade300a3224907cfdc961539bc1361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Rocabruna?= Date: Wed, 6 Nov 2024 23:59:45 +0100 Subject: [PATCH] ci(workflows): add GitHub Actions for coverage, docs, and test/lint automation - Added `coverage.yml` for automated code coverage reports with Codecov on pushes and pull requests to `main` - Created `docs.yml` to build Sphinx documentation on-demand, ensuring the latest documentation for workflow dispatch - Implemented `test-lint.yml` to automate testing, linting with flake8, and code formatting checks with black for consistency These workflows streamline CI/CD for testing, documentation, and coverage, improving project reliability and maintainability. --- .github/workflows/coverage.yml | 37 ++++++++++++++++++++++++++++++++ .github/workflows/docs.yml | 31 +++++++++++++++++++++++++++ .github/workflows/test-lint.yml | 38 +++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 .github/workflows/coverage.yml create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/test-lint.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..a80748f --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,37 @@ +name: Code Coverage + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + codecov: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Set up Python + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + with: + python-version: "3.12" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ".[dev]" + + - name: Run tests with coverage + run: pytest --cov=spacy_ewc --cov-report xml tests/ + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.xml + flags: unittests + name: codecov-umbrella + verbose: true diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..704e9c2 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,31 @@ +name: Documentation + +on: workflow_dispatch + +jobs: + build-docs: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Set up Python + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + with: + python-version: "3.12" + + - name: Install dependencies for docs + run: | + python -m pip install --upgrade pip + pip install ".[doc]" + + - name: Build Sphinx documentation + run: sphinx-build -b html docs/ docs/_build/ + + # Optional: Deploy to GitHub Pages + # - name: Deploy to GitHub Pages + # uses: peaceiris/actions-gh-pages@ + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # publish_dir: docs/_build diff --git a/.github/workflows/test-lint.yml b/.github/workflows/test-lint.yml new file mode 100644 index 0000000..56a0a1a --- /dev/null +++ b/.github/workflows/test-lint.yml @@ -0,0 +1,38 @@ +name: Test and Lint + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test-lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Set up Python + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + with: + python-version: "3.12" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ".[dev]" + + - name: Run tests + run: pytest -x --disable-warnings + + - name: Run linting with flake8 + run: | + flake8 spacy_ewc/ examples/ + + - name: Check code formatting with black + run: black --check spacy_ewc/ examples/ + + - name: Run EWC example script + run: python examples/ewc_ner_training_example.py