Add AWS components to support CI needs #49
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# The general flow of this is like so: | |
# | |
# - When a PR is opened against `main`, or if that PR changes: | |
# - Figure out if any code changes have been made | |
# - Require a version number change | |
# - Require that the code pass Ruff tests | |
# - When the PR gets merged: | |
# - Create a new branch matching the version number | |
name: validate | |
concurrency: | |
group: validate | |
cancel-in-progress: true | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- opened | |
- edited | |
- synchronize | |
- closed | |
permissions: | |
contents: read | |
pull-requests: read | |
jobs: | |
# This job detects which parts of the repo have been changed, setting future jobs up for conditional behavior. | |
detect-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
lint: ${{ steps.check.outputs.lint }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: check | |
with: | |
filters: | | |
lint: | |
- 'tb_pulumi/**' | |
- 'pyproject.toml' | |
# This job detects what version is listed in pyproject.toml and determines if a branch exists for that version yet. | |
detect-versions: | |
needs: detect-changes | |
if: needs.detect-changes.outputs.lint == 'true' | |
runs-on: ubuntu-latest | |
outputs: | |
branch-exists: ${{ steps.branch-exists.outputs.exists }} | |
version: v${{ steps.version.outputs.value }} | |
steps: | |
# Detect version from pyproject.toml | |
- uses: actions/checkout@v4 | |
- uses: SebRollen/toml-action@v1.2.0 | |
id: version | |
with: | |
file: './pyproject.toml' | |
field: project.version | |
- uses: GuillaumeFalourd/branch-exists@v1 | |
id: branch-exists | |
with: | |
branch: v${{ steps.version.outputs.value }} | |
# Run Ruff against tb_pulumi. Fail on format errors or failed sanity checks. | |
lint: | |
needs: detect-changes | |
runs-on: ubuntu-latest | |
if: needs.detect-changes.outputs.lint == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run Ruff syntax checks | |
uses: chartboost/ruff-action@v1 | |
with: | |
src: './tb_pulumi' | |
- name: Run Ruff linter | |
uses: chartboost/ruff-action@v1 | |
with: | |
src: './tb_pulumi' | |
args: 'format --check' | |
# The below code is commented out because it works, except for a Github auth issue. | |
# Ref: https://github.com/orgs/community/discussions/13836 | |
# When the PR gets merged, cut a new version branch. | |
# merge: | |
# needs: detect-versions | |
# if: github.event.pull_request.merged == true && needs.detect-versions.outputs.branch-exists == 'false' | |
# runs-on: ubuntu-latest | |
# permissions: | |
# contents: write | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Create a new version branch | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# shell: bash | |
# run: | | |
# git checkout -b ${{ needs.detect-versions.outputs.version }} | |
# git push -u origin ${{ needs.detect-versions.outputs.version }} |