Skip to content

Amruthvvkp/issue46

Amruthvvkp/issue46 #37

Workflow file for this run

name: PR Checks
on:
pull_request:
branches: [master]
types: [opened]
permissions:
contents: write
pull-requests: write
id-token: write
jobs:
linting_checks:
name: Validations with Ruff, Interrogate
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Run Ruff checks
uses: chartboost/ruff-action@v1
with:
src: "."
args: --format=github --target-version=py311
- name: Python Interrogate Check
uses: JackMcKew/python-interrogate-check@main
with:
path: flaui
badge-location: "badges/interrogate_badge.svg"
- name: Commit files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add badges/interrogate_badge.svg
git diff --exit-code || git commit -m "Update interrogate_badge.svg" -a
- name: Push changes
if: success()
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}
publish:
name: Publish to Test PyPI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Setup Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
poetry self add poetry-git-version-plugin
poetry config virtualenvs.in-project true
- name: Update Package Alpha Version
id: update_version
run: |
echo "Checking package version before publishing to Test PyPI"
poetry version
echo "Updating package version to alpha based on the latest head release tag"
poetry set-git-version
echo "UPGRADED_VERSION=$(poetry git-version)" >> $GITHUB_OUTPUT
- name: Build and publish distribution 📦 to Test PyPI
uses: JRubics/poetry-publish@v1.17
with:
pypi_token: ${{ secrets.TEST_PYPI_API_TOKEN }}
allow_poetry_pre_release: "yes"
ignore_dev_requirements: "yes"
repository_url: https://test.pypi.org/legacy/
repository_name: flaui-uiautomation-wrapper
- name: Commit files
run: |
git config user.email "actions@github.com"
git config user.name "GitHub Actions"
git add pyproject.toml
git commit -m "Bump version to $(poetry version | cut -d' ' -f2)"
- name: Push changes
if: success()
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}
- name: Comment on pull request
uses: actions/github-script@v6
env:
UPGRADED_PACKAGE_VERSION: ${{ steps.update_version.outputs.UPGRADED_VERSION }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// 1. Retrieve existing bot comments for the PR
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
const botComment = comments.find(comment => {
return comment.user.type === 'Bot' && comment.body.includes('Deployed to Test PyPI')
})
// 2. Prepare format of the comment
const output = `#### Deployed to Test PyPI 🚀
<details>
The package version \`${process.env.UPGRADED_PACKAGE_VERSION}\` has been published to Test PyPI. Please test and verify the package before publishing to PyPI - https://test.pypi.org/project/flaui-uiautomation-wrapper/${process.env.UPGRADED_PACKAGE_VERSION}/
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
// 3. If we have a comment, update it, otherwise create a new one
if (botComment) {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: output
})
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
}