From ee8d3b278120a294fe32a5e7b07afb692e1e7902 Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Thu, 9 Nov 2023 14:34:15 -0600 Subject: [PATCH] ci: Fixed and updated CICD pipeline - Fixed the Python version in the build, lint, test, and publish jobs - Added a strategy matrix for the Python version - Added a new step to build the project using Poetry - Added a new step to lint the code using black - Updated the test step to run pytest with verbose and capture mode - Added a new step to set up Python and install Poetry in the publish job - Updated the publish job to use the build and publish commands of Poetry --- .github/workflows/cicd.yml | 45 +++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index c2e08c4..151a2f9 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -9,43 +9,82 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.12 + python-version: ${{ matrix.python-version }} - name: Install Poetry run: | curl -sSL https://install.python-poetry.org | python3 - - name: Install dependencies run: | poetry install + - name: Build + run: | + poetry build lint: needs: build runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] steps: - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Poetry + run: | + curl -sSL https://install.python-poetry.org | python3 - + - name: Install dependencies + run: | + poetry install - name: Lint with flake8 run: | - poetry run flake8 your_package + poetry run black . --check test: needs: lint runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] steps: - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Poetry + run: | + curl -sSL https://install.python-poetry.org | python3 - + - name: Install dependencies + run: | + poetry install - name: Test with pytest run: | - poetry run pytest + poetry run pytest -v -s ./tests publish: needs: test if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] steps: - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} - name: Build and publish run: | poetry publish --username ${{ secrets.PYPI_USERNAME }} --password ${{ secrets.PYPI_PASSWORD }}