From a8223955f7d1c8aaae38607e8fd6b31b9d9fa3a6 Mon Sep 17 00:00:00 2001 From: JosePizarro3 Date: Tue, 28 May 2024 12:06:21 +0200 Subject: [PATCH] Revisit pipeline --- .../workflows/{actions.yaml => actions.yml} | 15 ++--- .github/workflows/mkdocs-deploy.yml | 31 ++++++--- .github/workflows/publish.yml | 4 +- .github/workflows2/build.yml | 63 ------------------- 4 files changed, 27 insertions(+), 86 deletions(-) rename .github/workflows/{actions.yaml => actions.yml} (68%) delete mode 100644 .github/workflows2/build.yml diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yml similarity index 68% rename from .github/workflows/actions.yaml rename to .github/workflows/actions.yml index 3784986..b6d776e 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yml @@ -12,20 +12,13 @@ jobs: - name: Install dependencies run: | pip install --upgrade pip - pip install '.[dev]' --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple - pip install coverage coveralls + pip install '.[dev]' - name: mypy run: | - python -m mypy --ignore-missing-imports --follow-imports=silent --no-strict-optional src/nomad_simulations tests + python -m mypy --ignore-missing-imports --follow-imports=silent --no-strict-optional src/pyssmf tests - name: Test with pytest run: | - python -m coverage run -m pytest -sv tests - - name: Submit to coveralls - continue-on-error: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - coveralls --service=github + python -m pytest -sv tests build-and-install: runs-on: ubuntu-latest steps: @@ -41,7 +34,7 @@ jobs: python -m build --sdist - name: Install the package run: | - pip install dist/*.tar.gz --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple + pip install dist/*.tar.gz ruff-linting: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/mkdocs-deploy.yml b/.github/workflows/mkdocs-deploy.yml index 6cebce1..e2bf95c 100644 --- a/.github/workflows/mkdocs-deploy.yml +++ b/.github/workflows/mkdocs-deploy.yml @@ -1,28 +1,41 @@ name: deploy-mkdocs - on: push: branches: - develop # Triggers deployment on push to the main branch - jobs: deploy: runs-on: ubuntu-latest - + needs: build # This ensures that the deployment job runs after the build job + if: github.ref == 'refs/heads/develop' # Only deployed for the develop branch steps: - name: Checkout Repository uses: actions/checkout@v4 - - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.x" - + python-version: 3.9 + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV + - uses: actions/cache@v3 + with: + key: mkdocs-material-${{ env.cache_id }} + path: .cache + restore-keys: | + mkdocs-material- + mkdocs-bibtex- - name: Install Dependencies run: | python -m pip install --upgrade pip pip install mkdocs mkdocs-material==8.1.1 pymdown-extensions mkdocs-click - - - name: Build and Deploy + - name: Build MKDocs Documentation + run: mkdocs build --verbose + - name: Deploy MKDocs to GitHub Pages run: | - mkdocs gh-deploy --config-file ../nomad-schema-plugin-simulation-data/mkdocs.yml --force --remote-branch gh-pages + if [ -n "$GITHUB_TOKEN" ]; then + mkdocs gh-deploy --force + else + echo "Set the GH_PAGES_TOKEN secret in your repository for deploying to GitHub Pages." + exit 1 + fi + env: + GITHUB_TOKEN: ${{ secrets.GH_PAGES_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f7fcff6..caaab6a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,12 +1,10 @@ # Upload python package to pypi server and github release. # Reference: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ -name: Upload Python Package - +name: upload-to-pypi on: release: types: [published] - jobs: # publish-to-pypi: # name: >- diff --git a/.github/workflows2/build.yml b/.github/workflows2/build.yml deleted file mode 100644 index 3c9ab86..0000000 --- a/.github/workflows2/build.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Build and Test, and Deploy MkDocs (for develop only) -on: - push: - branches: - - '*' -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.9 - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - name: Install Python dependencies - run: | - pip install --upgrade pip - pip install -r requirements.txt - - name: mypy - run: | - python -m mypy --explicit-package-bases --exclude=visualization.py src tests - - name: Test with `pytest` - if: success() || failure() - run: | - python -B -m pytest -sv tests - - name: Ruff check - run: | - ruff check --select=E,W,F,PL --ignore=E501,E701,E731,E402,PLR0911,PLR0912,PLR0913,PLR0915,PLR2004,PLW0603,PLW2901,PLR1714,PLR5501 --exclude=__init__.py --output-format=github . - deploy: - runs-on: ubuntu-latest - needs: build # This ensures that the deployment job runs after the build job - if: github.ref == 'refs/heads/develop' # Only deployed for the develop branch - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Setup Python 3.9 - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV - - uses: actions/cache@v3 - with: - key: mkdocs-material-${{ env.cache_id }} - path: .cache - restore-keys: | - mkdocs-material- - mkdocs-bibtex- - - name: Install Python dependencies - run: | - pip install --upgrade pip - pip install -r requirements.txt - - name: Build MKDocs Documentation - run: mkdocs build --verbose - - name: Deploy MKDocs to GitHub Pages - run: | - if [ -n "$GITHUB_TOKEN" ]; then - mkdocs gh-deploy --force - else - echo "Set the GH_PAGES_TOKEN secret in your repository for deploying to GitHub Pages." - exit 1 - fi - env: - GITHUB_TOKEN: ${{ secrets.GH_PAGES_TOKEN }}