Skip to content

Set up github workflows #9

Set up github workflows

Set up github workflows #9

Workflow file for this run

name: validate
concurrency:
group: validate
cancel-in-progress: true
#
on:
pull_request:
branches:
- 'main'
permissions:
contents: read
pull-requests: read
jobs:
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:
filters: |
lint:
- 'tb_pulumi/**'
- '.github/workflows/validate.yml'
- 'pyproject.toml'
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: actions/checkout@v4
- 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
if: needs.detect-changes.outputs.lint == 'true'
steps:
- uses: actions/checkout@v4
- name: Quick lint with Ruff
uses: chartboost/ruff-action@v1
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 }}