Skip to content

Commit

Permalink
Add version checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjjung committed Sep 30, 2024
1 parent 4d00d17 commit 3aaf085
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ permissions:
pull-requests: read

jobs:
# Main filter detecting where in the repo changes have been made, allowing us to be smart about how we respond

detect-changes:
runs-on: ubuntu-latest
outputs:
lint: ${{ steps.check.outputs.lint }}
steps:
- uses: actions/checkout@v4

# Take different actions depending on what changed
- uses: dorny/paths-filter@v3
id: check
with:
Expand All @@ -31,7 +32,33 @@ jobs:
- 'tb_pulumi/**'
- '.github/workflows/validate.yml'
# Run Ruff against tb_pulumi
detect-versions:
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: SebRollen/[email protected]
id: version
with:
file: pyproject.toml
field: project.version
- uses: GuillaumeFalourd/branch-exists@v1
id: branch-exists
with:
branch: v${{ steps.version.outputs.value }}

# Fail on version collision
version-collision:
needs: detect-versions
runs-on: ubuntu-latest
if: needs.detect-versions.outputs.branch-exists == 'true'
steps:
- name: "Error: version collision"
run: exit 1

# Run Ruff, our linter, against tb_pulumi
lint:
needs: detect-changes
runs-on: ubuntu-latest
Expand All @@ -44,3 +71,17 @@ jobs:
with:
src: './tb_pulumi'
args: 'format --check'

# Cut a new branch if there isn't one with this version number
# cut-version-branch:
# needs: detect-versions
# runs-on: ubuntu-latest
# permissions:
# contents: write
# if: needs.detect-versions.outputs.branch-exists == 'false'
# steps:
# - name: Create a new version branch
# uses: peterjgrainger/[email protected]
# with:
# branch: ${{ needs.detect-versions.outputs.version }}
# sha: ${{ github.event.pull_request.head.sha }}

0 comments on commit 3aaf085

Please sign in to comment.