Skip to content

Commit

Permalink
Update the build workflow for GitHub Actions
Browse files Browse the repository at this point in the history
Pull in the current version in cisagov/skeleton-python-library as that
is the most comparable to the current workflow definition. This is
necessary to fix testing Python 3.6.
  • Loading branch information
mcdonnnj committed May 6, 2023
1 parent 78834dd commit 0ea5ebb
Showing 1 changed file with 96 additions and 27 deletions.
123 changes: 96 additions & 27 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,24 @@ jobs:
uses: cisagov/setup-env-github-action@develop
- uses: actions/checkout@v3
- id: setup-python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"
# We need the Go version and Go cache location for the actions/cache step,
# so the Go installation must happen before that.
- uses: actions/setup-go@v2
- id: setup-go
uses: actions/setup-go@v4
with:
go-version: "1.16"
- name: Store installed Go version
id: go-version
run: |
echo "::set-output name=version::"\
"$(go version | sed 's/^go version go\([0-9.]\+\) .*/\1/')"
go-version: "1.19"
- name: Lookup Go cache directory
id: go-cache
run: |
echo "::set-output name=dir::$(go env GOCACHE)"
echo "dir=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
env:
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
py${{ steps.setup-python.outputs.python-version }}-\
go${{ steps.go-version.outputs.version }}-\
go${{ steps.setup-go.outputs.go-version }}-\
packer${{ steps.setup-env.outputs.packer-version }}-\
tf${{ steps.setup-env.outputs.terraform-version }}-"
with:
Expand Down Expand Up @@ -82,7 +78,7 @@ jobs:
${{ env.CURL_CACHE_DIR }}/"${PACKER_ZIP}"
sudo mv /usr/local/bin/packer /usr/local/bin/packer-default
sudo ln -s /opt/packer/packer /usr/local/bin/packer
- uses: hashicorp/setup-terraform@v1
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ steps.setup-env.outputs.terraform-version }}
- name: Install shfmt
Expand All @@ -97,7 +93,7 @@ jobs:
run: go install ${PACKAGE_URL}@${PACKAGE_VERSION}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip setuptools wheel
pip install --upgrade --requirement requirements-test.txt
- name: Set up pre-commit hook environments
run: pre-commit install-hooks
Expand All @@ -107,20 +103,26 @@ jobs:
uses: mxschmitt/action-tmate@v3
if: env.RUN_TMATE
test:
runs-on: ubuntu-latest
name: test source - py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
python-version:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
include:
- os: ubuntu-20.04
python-version: "3.6"
steps:
- uses: actions/checkout@v3
- id: setup-python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
Expand Down Expand Up @@ -159,11 +161,12 @@ jobs:
if: env.RUN_TMATE
coveralls-finish:
runs-on: ubuntu-latest
needs: test
needs:
- test
steps:
- uses: actions/checkout@v3
- id: setup-python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: actions/cache@v3
Expand Down Expand Up @@ -193,21 +196,29 @@ jobs:
uses: mxschmitt/action-tmate@v3
if: env.RUN_TMATE
build:
runs-on: ubuntu-latest
needs: [lint, test]
name: build wheel - py${{ matrix.python-version }}
needs:
- lint
- test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
python-version:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
include:
- os: ubuntu-20.04
python-version: "3.6"
steps:
- uses: actions/checkout@v3
- id: setup-python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
Expand All @@ -224,17 +235,75 @@ jobs:
${{ hashFiles('setup.py') }}"
restore-keys: |
${{ env.BASE_CACHE_KEY }}
- name: Install dependencies
- name: Install build dependencies
run: |
python -m pip install --upgrade pip wheel
pip install --upgrade --requirement requirements.txt
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade build
- name: Build artifacts
run: python3 setup.py sdist bdist_wheel
run: python -m build
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: dist-${{ matrix.python-version }}
path: dist
- name: Setup tmate debug session
uses: mxschmitt/action-tmate@v3
if: env.RUN_TMATE
test-build:
name: test built wheel - py${{ matrix.python-version }}
needs:
- build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
include:
- os: ubuntu-20.04
python-version: "3.6"
steps:
- uses: actions/checkout@v3
- id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
env:
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
py${{ steps.setup-python.outputs.python-version }}-"
with:
path: ${{ env.PIP_CACHE_DIR }}
# We do not use '**/setup.py' in the cache key so only the 'setup.py'
# file in the root of the repository is used. This is in case a Python
# package were to have a 'setup.py' as part of its internal codebase.
key: "${{ env.BASE_CACHE_KEY }}\
${{ hashFiles('**/requirements.txt') }}-\
${{ hashFiles('setup.py') }}"
restore-keys: |
${{ env.BASE_CACHE_KEY }}
- name: Retrieve the built wheel
uses: actions/download-artifact@v3
with:
name: dist-${{ matrix.python-version }}
path: dist
- id: find-wheel
name: Get the name of the retrieved wheel (there should only be one)
run: echo "wheel=$(ls dist/*whl)" >> $GITHUB_OUTPUT
- name: Update core Python packages
run: python -m pip install --upgrade pip setuptools wheel
- name: Install the built wheel (along with testing dependencies)
run: python -m pip install ${{ steps.find-wheel.outputs.wheel }}[test]
- name: Run tests
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: pytest
- name: Setup tmate debug session
uses: mxschmitt/action-tmate@v3
if: env.RUN_TMATE

0 comments on commit 0ea5ebb

Please sign in to comment.