-
Notifications
You must be signed in to change notification settings - Fork 3
146 lines (126 loc) · 4.79 KB
/
pr-checks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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
})
}