diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml index 7941848..94778e4 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/python-build.yml @@ -13,6 +13,20 @@ on: required: false type: string default: "src" + docker-container: + description: "Docker container to run as part of build" + required: false + type: string + docker-compose-env: + description: "env to set for docker compose as a JSON string" + required: false + type: string + default: "" + python-versions-to-test: + description: "List of versions of python to run, as a JSON string" + required: false + type: string + default: "['3.10']" secrets: LC_URL: required: false @@ -123,13 +137,20 @@ jobs: build-and-test: runs-on: ubuntu-latest needs: [check-for-leaks, run-checks] - container: python:3.10 + strategy: + matrix: + python-version: ${{ fromJSON(inputs.python-versions-to-test) }} env: GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + architecture: 'x64' + - name: Install dependencies run: | pip install tox @@ -140,9 +161,23 @@ jobs: git config --global --add safe.directory /__w/$dname/$dname shell: sh + - name: Login to Docker Hub + if: inputs.docker-container != '' + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.CI_GITHUB_TOKEN }} + + - name: Stand up required service containers, and run code generation + if: inputs.docker-container != '' + env: ${{ fromJSON(inputs.docker-compose-env }} + run: | + docker compose up ${{ inputs.docker-container }} + - name: Build and test run: | - tox + tox -e py${{ matrix.python-version }} shell: bash - name: Upload coverage to Codecov diff --git a/.github/workflows/python-lib-release.yml b/.github/workflows/python-lib-release.yml index 2f38412..6aaa2af 100644 --- a/.github/workflows/python-lib-release.yml +++ b/.github/workflows/python-lib-release.yml @@ -19,6 +19,20 @@ on: required: false type: string default: "src" + docker-container: + description: "Docker container to run as part of build" + required: false + type: string + docker-compose-env: + description: "env to set for docker compose as a JSON string" + required: false + type: string + default: "" + python-version: + description: "Python versions to run 'build'" + required: false + type: string + default: 3.10 secrets: CI_GITHUB_TOKEN: @@ -143,7 +157,7 @@ jobs: python-deps-check: needs: release-checks runs-on: ubuntu-latest - container: python:3.10 + container: python:${{ inputs.python-version }} steps: - uses: actions/checkout@v4 @@ -166,7 +180,7 @@ jobs: needs: [release-checks, build-docs] if: always() && !failure() && !cancelled() runs-on: ubuntu-latest - container: python:3.10 + container: python:${{ inputs.python-version }} outputs: artifact: ${{ steps.build.outputs.artifact }} steps: @@ -198,10 +212,24 @@ jobs: echo "password = $PYPI_API_TOKEN" >> ~/.pypirc echo "\n" >> ~/.pypirc + - name: Login to Docker Hub + if: inputs.docker-container != '' + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.CI_GITHUB_TOKEN }} + + - name: Stand up required service containers, and run code generation + if: inputs.docker-container != '' + env: ${{ fromJSON(inputs.docker-compose-env }} + run: | + docker compose up ${{ inputs.docker-container }} + - name: Build and publish id: build run: | - tox + tox -e py${{ inputs.python-version }} twine upload --non-interactive --config-file ~/.pypirc dist/* artifact_id=$(cat pyproject.toml | grep '[[:space:]]*name[[:space:]]*=[[:space:]]*".*"$' | cut -d\" -f2 | tr -d '"' | sed 's-\.-_-g') artifact="${artifact_id}-${{ needs.release-checks.outputs.version }}-py3-none-any.whl" diff --git a/.github/workflows/python-lib-snapshot.yml b/.github/workflows/python-lib-snapshot.yml index 64364c6..2a26c89 100644 --- a/.github/workflows/python-lib-snapshot.yml +++ b/.github/workflows/python-lib-snapshot.yml @@ -18,6 +18,15 @@ on: required: false type: string default: "src" + docker-container: + description: "Docker container to run as part of build" + required: false + type: string + python-version: + description: "Python versions to run 'build'" + required: false + type: string + default: 3.10 #pypi-project-name: # OPS-185, although this could be replaced by parsing the name from .pyproject.toml? # description: 'The Pypi project to deploy to - should be the package name' # required: true @@ -98,7 +107,7 @@ jobs: deploy: runs-on: ubuntu-latest - container: python:3.10 + container: python:${{ inputs.python-version }} needs: [run-checks] env: GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} @@ -128,11 +137,24 @@ jobs: echo "password = $PYPI_API_TOKEN" >> ~/.pypirc echo "\n" >> ~/.pypirc + - name: Login to Docker Hub + if: inputs.docker-container != '' + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.CI_GITHUB_TOKEN }} + + - name: Stand up required service containers, and run code generation + if: inputs.docker-container != '' + run: | + docker compose up ${{ inputs.docker-container }} + - name: Build and publish env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} run: | - tox + tox -e py${{ inputs.python-version }} twine upload --verbose --non-interactive --config-file ~/.pypirc dist/* shell: bash