Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build CLI Package Validation

on:
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- ready_for_review

permissions:
contents: read

jobs:
build:
name: Build Package
runs-on: ubuntu-latest
needs:
- test # Ensure all test jobs complete successfully
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Create and activate Virtual Environment
run: |
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

- name: Validate build package
run: |
source venv/bin/activate
python -m build
137 changes: 0 additions & 137 deletions .github/workflows/fab-build.yml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Lint Code

on:
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- ready_for_review

permissions:
contents: read

jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12" # Use any stable Python version for linting

- name: Install Tox
run: |
python -m pip install --upgrade pip
pip install tox

- name: Cache Tox environments
uses: actions/cache@v3
with:
path: .tox
key: ${{ runner.os }}-tox-lint-${{ hashFiles('**/tox.toml') }}
restore-keys: |
${{ runner.os }}-tox-lint-

- name: Run Linting
run: tox -e lint
116 changes: 116 additions & 0 deletions .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Linter to enforce semantic pull request titles (see https://www.conventionalcommits.org/)
---
name: 🔍 Semantic PR Validation

on:
pull_request:
branches:
- main
types:
- opened
- edited
- reopened
- ready_for_review

permissions:
pull-requests: write

jobs:
check_pr_title:
name: Check Pull Request Title
runs-on: ubuntu-latest
steps:
- name: Run Semantic PR Validation
id: validation
uses: actions/github-script@v6
with:
script: |
const prTitle = context.payload.pull_request.title;
const regex = /^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\([^)]+\))?(!?): .+/;

if (!regex.test(prTitle)) {
core.setFailed('Pull request title does not follow Conventional Commits specification. See PR comment for details.');
}
- name: Handle Invalid Title
if: failure()
uses: actions/github-script@v6
with:
script: |
const commentMarker = '<!-- semantic-pr-comment -->';

const { data: comments } = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});

const existingComment = comments.find(comment => comment.body.includes(commentMarker));

if (!existingComment) {
const message = `<!-- semantic-pr-comment -->

Hey there and thank you for your contribution! 👋🏼

We require pull request titles to follow the [Conventional Commits](https://www.conventionalcommits.org/) specification and it looks like your proposed title needs to be adjusted.

A valid title has the format: \`type(scope): subject\`

**type**: Must be one of the following:
- \`feat\`: A new feature
- \`fix\`: A bug fix
- \`docs\`: Documentation only changes
- \`style\`: Changes that do not affect the meaning of the code (e.g., formatting)
- \`refactor\`: A code change that neither fixes a bug nor adds a feature
- \`perf\`: A code change that improves performance
- \`test\`: Adding missing tests or correcting existing tests
- \`chore\`: Changes to the build process or auxiliary tools
- \`build\`: Changes that affect the build system or external dependencies
- \`ci\`: Changes to CI configuration files and scripts
- \`revert\`: Reverts a previous commit

**scope** (optional): A noun describing a section of the codebase.

**subject**: A short description of the code changes.

Examples:
- \`feat(api): add new endpoint for users\`
- \`fix: correct a typo in the documentation\`
- \`docs(readme): update installation instructions\`

Please update your pull request title to match this format.`;

await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});
}

await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['invalid']
});
- name: Handle Valid Title
if: success()
uses: actions/github-script@v6
with:
script: |
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const invalidLabel = labels.find(label => label.name === 'invalid');

if (invalidLabel) {
await github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'invalid',
});
}
Loading