Skip to content

Commit

Permalink
ci(workflows): add GitHub Actions for coverage, docs, and test/lint a…
Browse files Browse the repository at this point in the history
…utomation

- 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.
  • Loading branch information
JRocabruna committed Nov 6, 2024
1 parent e0b5f22 commit c8771b2
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -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@<latest_commit_sha_for_gh_pages>
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: docs/_build
38 changes: 38 additions & 0 deletions .github/workflows/test-lint.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c8771b2

Please sign in to comment.