Skip to content

Commit

Permalink
use github environments to store config
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Jan 26, 2024
1 parent 9fc50d5 commit c69ded0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/actions/publish-pypi/action.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# requires github environment with PYPI_REPOSITORY_URL defined
name: Publish PyPI

inputs:
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/publish-results/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
description: File type for file name stub (e.g. "unit-tests")
required: true
python-version:
description: Create an environment with the appropriate version of python and hatch installed
description: Python version for the file name stub (e.g. "3.8")
required: true
source-file:
description: File to be uploaded
Expand All @@ -16,10 +16,10 @@ runs:
steps:
- name: Get timestamp
id: timestamp
run: echo "ts=$(date +'%Y-%m-%dT%H_%M_%S')" >> $GITHUB_OUTPUT #no colons allowed for artifacts
run: echo "ts=$(date +'%Y-%m-%dT%H-%M-%S')" >> $GITHUB_OUTPUT #no colons allowed for artifacts
shell: bash

- uses: actions/upload-artifact@v3
with:
name: ${{ inputs.file-name }}_${{ inputs.python-version }}-${{ steps.timestamp.outputs.ts }}.csv
name: ${{ inputs.file-name }}_python-${{ inputs.python-version }}_${{ steps.timestamp.outputs.ts }}.csv
path: ${{ inputs.source-file }}
7 changes: 5 additions & 2 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ inputs:
setup-command:
description: The command to setup development dependencies
default: "python -m pip install hatch"
python-version:
description: The python version to use
required: true

runs:
using: composite
steps:
- name: Set up Python ${{ vars.PYTHON_VERSION }}
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ vars.PYTHON_VERSION }}
python-version: ${{ inputs.python-version }}

- name: Install dev dependencies
run: ${{ inputs.setup-command }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ on:

permissions: read-all

defaults:
run:
shell: bash

# will cancel previous workflows triggered by the same event and for the same ref for PRs or same SHA otherwise
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }}
cancel-in-progress: true

jobs:
lint:
name: Python 3.8
name: Python ${{ vars.PYTHON_DEFAULT_VERSION }}
runs-on: ubuntu-latest
environment:
name: ci

steps:
- name: Check out repository
Expand All @@ -29,12 +35,10 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-environment
with:
python-version: "3.8"
python-version: ${{ vars.PYTHON_DEFAULT_VERSION }}

- name: Run linters
run: hatch run lint:all
shell: bash

- name: Run typechecks
run: hatch run typecheck:all
shell: bash
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup-environment
with:
python-version: ${{ vars.PYTHON_VERSION }}

# keep this in the workflow so that the publishing actions are generic
- name: Change working directory if `dbt-tests-adapter`
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ jobs:
unit:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
environment:
name: ci

strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ${{ vars.PYTHON_SUPPORTED_VERSIONS }}

steps:
- name: Check out repository
Expand Down

0 comments on commit c69ded0

Please sign in to comment.