From b896b609a9c26249bff8bea8ca3a92e048f93b3a Mon Sep 17 00:00:00 2001 From: Asa Rentschler Date: Mon, 30 Dec 2024 13:40:40 -0500 Subject: [PATCH] New workflows --- .github/workflows/build.yaml | 35 +++++++++++++++ .../{documentation.yml => docs.yaml} | 26 +++++------ .github/workflows/linter.yaml | 28 ++++++++++++ .github/workflows/python-publish.yml | 43 ------------------- .github/workflows/release.yaml | 30 +++++++++++++ .github/workflows/tests.yaml | 25 +++++++++++ README.md | 7 +++ pyproject.toml | 2 +- 8 files changed, 137 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/build.yaml rename .github/workflows/{documentation.yml => docs.yaml} (56%) create mode 100644 .github/workflows/linter.yaml delete mode 100644 .github/workflows/python-publish.yml create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..27d0f0d --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,35 @@ +on: + release: + types: + - published + +name: build + +permissions: + contents: read + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout ${{ github.ref_name }} + uses: actions/checkout@v4 + with: + ref: ${{ github.ref_name }} + fetch-tags: true + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build Python Package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + verbose: true diff --git a/.github/workflows/documentation.yml b/.github/workflows/docs.yaml similarity index 56% rename from .github/workflows/documentation.yml rename to .github/workflows/docs.yaml index 7a1a355..69776bd 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/docs.yaml @@ -1,20 +1,16 @@ -# Deploy Velocity documentation -name: Deploy Documentation to Pages - on: - # trigger on push to develop also allow manual runs push: - branches: ["develop"] - workflow_dispatch: + branches: + - develop + workflow_dispatch: { } + +name: docs -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read pages: write id-token: write -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: group: "pages" cancel-in-progress: false @@ -26,24 +22,24 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout Develop uses: actions/checkout@v4 with: - ref: "develop" + ref: develop - name: Setup Pages uses: actions/configure-pages@v5 - - name: Set up Python + - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.10' - - name: Install dependencies + python-version: '3.12' + - name: Install Dependencies run: | python -m pip install --upgrade pip pip install sphinx sphinx-rtd-theme sphinx-copybutton - name: Build Docs run: | cd docs && make html - - name: Upload documentation HTML files + - name: Upload HTML Files uses: actions/upload-pages-artifact@v3 with: path: './docs/build/html' diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml new file mode 100644 index 0000000..cc42815 --- /dev/null +++ b/.github/workflows/linter.yaml @@ -0,0 +1,28 @@ +on: + push: + branches: + - develop + - releases/** + pull_request: + branches: + - develop + - releases/** + +name: Lint Code + +jobs: + lint: + name: Run Linter + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: "${{ github.ref }}" + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: | + python -m pip install --upgrade pip + pip install ruff + - run: | + python3 -m unittest diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml deleted file mode 100644 index f6b13f0..0000000 --- a/.github/workflows/python-publish.yml +++ /dev/null @@ -1,43 +0,0 @@ -# This workflow will upload a Python Package using Twine when a release is created -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Upload Python Package - -on: - release: - types: [published] - -permissions: - contents: read - -jobs: - deploy: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.ref_name }} - fetch-tags: true - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - verbose: true diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..25ad504 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,30 @@ +on: + push: + tags: + - v[0-9]* + +run-name: Release ${{ github.ref_name }} + +permissions: + contents: write + +jobs: + release: + name: Create Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + with: + fetch-depth: 0 + ref: ${{ github.ref }} + - env: + GH_TOKEN: ${{ github.token }} + run: | + echo "LATEST_RELEASE=$(gh release list | awk '$2 == "Latest" {print $3}')" >> "$GITHUB_ENV" + - env: + GH_TOKEN: ${{ github.token }} + run: | + gh release create "${{ github.ref_name }}" \ + --repo="$GITHUB_REPOSITORY" \ + --title="${{ github.ref_name }}" \ + --notes="Changes between: $LATEST_RELEASE..${{ github.ref_name }}\n$(git log $LATEST_RELEASE..${{ github.ref_name }} --oneline --decorate=false)" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..c395582 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,25 @@ +on: + push: + branches: + - develop + - releases/** + pull_request: + branches: + - develop + - releases/** + +name: Run Unit Tests + +jobs: + test: + name: Run Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: "${{ github.ref }}" + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: | + python3 -m unittest diff --git a/README.md b/README.md index 41f93e7..ae908a7 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ ----------------------------------------------------------- +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/olcf/velocity/tests?event=push&style=flat-square&label=test) +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/olcf/velocity/docs?branch=develop&event=push&style=flat-square&label=deploy%20docs) +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/olcf/velocity/build?event=release&style=flat-square&label=build) +[![PyPI - Version](https://img.shields.io/pypi/v/olcf-velocity?style=flat-square&color=%23FFD242)](https://pypi.org/project/olcf-velocity) +[![Spack](https://img.shields.io/spack/v/py-olcf-velocity?style=flat-square&color=%230F3A80)](https://packages.spack.io/package.html?name=py-olcf-velocity) + ## Description Velocity is a tool to help with the maintenance of container build scripts on multiple systems, backends (e.g podman or apptainer) and distros. @@ -13,4 +19,5 @@ See . ``` commandline pip install olcf-velocity alias velocity="python3 -m velocity" +velocity ``` diff --git a/pyproject.toml b/pyproject.toml index 5a1d4f0..8614cfa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ exclude = [ ] line-length = 120 indent-width = 4 -target-version = "py310" +target-version = "py312" [tool.ruff.lint] select = ["E4", "E7", "E9", "F"]