From c7ba0c7412e9681ea9a5413ff863530fee41975b Mon Sep 17 00:00:00 2001 From: LegrandNico Date: Mon, 14 Oct 2024 14:43:03 +0200 Subject: [PATCH] actions --- .github/workflows/docs.yml | 15 ++++++---- .github/workflows/test.yml | 60 +++++++++++++++++++++++++------------- 2 files changed, 49 insertions(+), 26 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 76a2e078a..17b9c1a28 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,21 +13,25 @@ jobs: build-and-deploy: runs-on: ubuntu-latest steps: + # 1. Checkout the repository - name: Checkout 🛎️ uses: actions/checkout@v4 + # 2. Set up Python 3.12 - name: Set up Python 3.12 uses: actions/setup-python@v5 with: python-version: '3.12' - - name: Build + # 3. Install dependencies and build the documentation + - name: Install dependencies and build docs run: | - sudo apt-get install graphviz + apt-get install graphviz pip install poetry poetry-dynamic-versioning poetry install --with dev - sphinx-build -j 4 -T -b html docs/source docs/build/html + poetry run sphinx-build -j 4 -T -b html docs/source docs/build/html + # 4. Deploy the documentation for the 'release' event - name: Deploy Stable 🚀 if: github.event_name == 'release' uses: JamesIves/github-pages-deploy-action@v4 @@ -35,10 +39,11 @@ jobs: folder: docs/build/html branch: gh-pages + # 5. Deploy the documentation for pull requests (Dev version) - name: Deploy Dev 🚀 - if: (github.event_name == 'pull_request') || (github.event_name == 'push') + if: github.event_name == 'pull_request' uses: JamesIves/github-pages-deploy-action@v4 with: folder: docs/build/html branch: gh-pages - target-folder: dev + target-folder: dev \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eb0b8cd6c..02f1ffb90 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,34 +5,52 @@ on: branches: - master pull_request: + # This will run the action for pull requests from any branch branches: - - "*" + - '*' + jobs: test: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.12'] + python-version: ['3.12'] # Add more Python versions if needed, like '3.8', '3.9', '3.10', etc. + steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install Poetry - run: | + # Step 1: Checkout the repository + - name: Checkout Repository + uses: actions/checkout@v4 + + # Step 2: Set up Python environment + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + # Step 3: Install Poetry + - name: Install Poetry + run: | curl -sSL https://install.python-poetry.org | python3 - echo "$HOME/.local/bin" >> $GITHUB_PATH poetry self add "poetry-dynamic-versioning[plugin]" - - name: Install dependencies - run: | - sudo apt-get install graphviz - poetry install --with dev - python -m ipykernel install --user --name python3 - - name: Run tests and coverage - run: | - pytest ./tests/ --cov=./src/pyhgf/ --cov-report=xml - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} # required + + # Step 4: Install System Dependencies + - name: Install Graphviz + run: apt-get install -y graphviz + + # Step 5: Install Python Dependencies using Poetry + - name: Install dependencies + run: | + poetry install --with dev + python -m ipykernel install --user --name python3 + + # Step 6: Run Tests and Generate Coverage Report + - name: Run tests and coverage + run: | + poetry run pytest ./tests/ --cov=./src/pyhgf/ --cov-report=xml + + # Step 7: Upload Coverage Report to Codecov + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} # Make sure to set this token in repository secrets