diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..2b07bfcd --- /dev/null +++ b/.github/workflows/build.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/fab-build.yml b/.github/workflows/fab-build.yml deleted file mode 100644 index e24452cd..00000000 --- a/.github/workflows/fab-build.yml +++ /dev/null @@ -1,137 +0,0 @@ -name: fab:build - -on: - pull_request: - branches: - - main - -permissions: - contents: read - -jobs: - # Linting Job - 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 - - - # Type Checking Job - type-check: - name: Type Check 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 type checking - - - 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-type-${{ hashFiles('**/tox.toml') }} - restore-keys: | - ${{ runner.os }}-tox-type- - - - name: Run Type Checks - run: tox -e type - - # Testing Jobs with Matrix Strategy - test: - name: Test on Python ${{ matrix.python-version }} - runs-on: ubuntu-latest - strategy: - matrix: - include: - - python-version: "3.10" - tox-env: "py310" - - python-version: "3.11" - tox-env: "py311" - - python-version: "3.12" - tox-env: "py312" - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - 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-${{ matrix.tox-env }}-${{ hashFiles('**/tox.toml') }} - restore-keys: | - ${{ runner.os }}-tox-${{ matrix.tox-env }}- - ${{ runner.os }}-tox- - - - name: Run Tests - run: tox -e ${{ matrix.tox-env }} - - # Upload the coverage report as an artifact - - name: Upload coverage artifact - uses: actions/upload-artifact@v4 - with: - name: coverage-html-report-${{ matrix.python-version }} - path: coverage_html - - # Build Job - 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: Build package - run: | - source venv/bin/activate - python -m build diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..19c2e379 --- /dev/null +++ b/.github/workflows/lint.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml new file mode 100644 index 00000000..26b2dec0 --- /dev/null +++ b/.github/workflows/semantic-pr.yml @@ -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 = ''; + + 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 = ` + + 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', + }); + } \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..a494abc3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,59 @@ +name: Run Tests + +on: + pull_request: + branches: + - main + types: + - opened + - reopened + - synchronize + - ready_for_review + +permissions: + contents: read + +jobs: + test: + name: Test on Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + strategy: + matrix: + include: + - python-version: "3.10" + tox-env: "py310" + - python-version: "3.11" + tox-env: "py311" + - python-version: "3.12" + tox-env: "py312" + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - 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-${{ matrix.tox-env }}-${{ hashFiles('**/tox.toml') }} + restore-keys: | + ${{ runner.os }}-tox-${{ matrix.tox-env }}- + ${{ runner.os }}-tox- + + - name: Run Tests + run: tox -e ${{ matrix.tox-env }} + + # Upload the coverage report as an artifact + - name: Upload coverage artifact + uses: actions/upload-artifact@v4 + with: + name: coverage-html-report-${{ matrix.python-version }} + path: coverage_html \ No newline at end of file diff --git a/.github/workflows/type-check.yml b/.github/workflows/type-check.yml new file mode 100644 index 00000000..429af648 --- /dev/null +++ b/.github/workflows/type-check.yml @@ -0,0 +1,42 @@ +name: Type Check Code + +on: + pull_request: + branches: + - main + types: + - opened + - reopened + - synchronize + - ready_for_review + +permissions: + contents: read + +jobs: + type-check: + name: Run Type Check 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 type checking + + - 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-type-${{ hashFiles('**/tox.toml') }} + restore-keys: | + ${{ runner.os }}-tox-type- + + - name: Run Type Checks + run: tox -e type \ No newline at end of file