Skip to content

Commit 21f4035

Browse files
committed
cherry-pick updates to relase tooling
1 parent d0b5083 commit 21f4035

File tree

5 files changed

+90
-23
lines changed

5 files changed

+90
-23
lines changed

.github/workflows/Comment-on-PR.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
on:
22
pull_request_target:
3-
paths:
4-
- '*'
5-
- '!docs/Coding-Conventions.md'
3+
paths-ignore:
4+
- "docs/Coding-Conventions.md"
5+
types:
6+
- opened
7+
- reopened
68

79
jobs:
810
comment_on_pr:
@@ -11,7 +13,7 @@ jobs:
1113
steps:
1214
- name: Checkout
1315
uses: actions/checkout@v3
14-
16+
1517
- name: Comment on PR
1618
uses: thollander/actions-comment-pull-request@v1
1719
with:

.github/workflows/Notify-Convention-Change.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request_target:
55
paths:
66
- docs/Coding-Conventions.md
7+
types:
8+
- opened
9+
- reopened
710

811
jobs:
912
org-check:
@@ -26,7 +29,6 @@ jobs:
2629
2730
Since this changes the Coding Conventions, I'll @-mention the appropriate NI engineers.
2831
@alejandro5042
29-
@alexweav
3032
@DavidCurtiss
3133
@irwand
3234
@jryckman

.github/workflows/PR.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
- .github/workflows/PR.yml
1313

1414
env:
15-
POETRY_VERSION: 1.1.6
15+
POETRY_VERSION: 1.2.2
1616

1717
jobs:
1818
checks:
@@ -24,18 +24,14 @@ jobs:
2424
- uses: actions/setup-python@v2
2525
with:
2626
python-version: ${{ env.PYTHON_VERSION }}
27-
- uses: Gr1N/setup-poetry@v4
27+
- uses: Gr1N/setup-poetry@v8
2828
with:
2929
poetry-version: ${{ env.POETRY_VERSION }}
3030
# @TODO: This is a workaround for there not being a way to check the lock file
3131
# See: https://github.com/python-poetry/poetry/issues/453
3232
- name: Check for lock changes
3333
run: |
34-
PYTHONPATH="${PYTHONPATH}:${HOME}/.poetry/lib:${HOME}/.poetry/lib/poetry/_vendor/py${{ env.PYTHON_VERSION }}" \
35-
python -c "from poetry.factory import Factory; \
36-
locker = Factory().create_poetry('.').locker; \
37-
exit(0) if locker.is_locked() and locker.is_fresh() else exit(1)" \
38-
&& echo 'OK'
34+
poetry lock --check
3935
- uses: actions/cache@v2
4036
with:
4137
path: ~/.cache/pypoetry/virtualenvs
@@ -50,14 +46,14 @@ jobs:
5046
strategy:
5147
matrix:
5248
os: [macos-latest, windows-latest, ubuntu-latest]
53-
python-version: [3.6, 3.7, 3.8, 3.9]
49+
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']
5450
steps:
5551
- uses: actions/checkout@v2
5652
- uses: actions/setup-python@v2
5753
with:
5854
python-version: ${{ matrix.python-version }}
5955

60-
- uses: Gr1N/setup-poetry@v4
56+
- uses: Gr1N/setup-poetry@v8
6157
with:
6258
poetry-version: ${{ env.POETRY_VERSION }}
6359
- uses: actions/cache@v2

.github/workflows/Publish-Package.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
env:
88
# Versions are also listed in PR.yml
9-
POETRY_VERSION: 1.1.6
9+
POETRY_VERSION: 1.2.2
1010
PYTHON_VERSION: 3.9 # Use latest
1111

1212
jobs:
@@ -23,18 +23,14 @@ jobs:
2323
- uses: actions/setup-python@v2
2424
with:
2525
python-version: ${{ env.PYTHON_VERSION }}
26-
- uses: Gr1N/setup-poetry@v4
26+
- uses: Gr1N/setup-poetry@v8
2727
with:
2828
poetry-version: ${{ env.POETRY_VERSION }}
2929
# @TODO: This is a workaround for there not being a way to check the lock file
3030
# See: https://github.com/python-poetry/poetry/issues/453
3131
- name: Check for lock changes
3232
run: |
33-
PYTHONPATH="${PYTHONPATH}:${HOME}/.poetry/lib:${HOME}/.poetry/lib/poetry/_vendor/py${{ env.PYTHON_VERSION }}" \
34-
python -c "from poetry.factory import Factory; \
35-
locker = Factory().create_poetry('.').locker; \
36-
exit(0) if locker.is_locked() and locker.is_fresh() else exit(1)" \
37-
&& echo 'OK'
33+
poetry lock --check
3834
- uses: actions/cache@v2
3935
with:
4036
path: ~/.cache/pypoetry/virtualenvs
@@ -71,7 +67,8 @@ jobs:
7167
7268
- name: Push changes
7369
if: ${{ github.event.release.target_commitish == 'main' }}
74-
uses: ad-m/github-push-action@master
70+
uses: CasperWA/push-protected@v2
7571
with:
76-
github_token: ${{ secrets.ADMIN_PAT }}
72+
token: ${{ secrets.ADMIN_PAT }}
7773
branch: ${{ github.event.release.target_commitish }}
74+
unprotect_reviews: true
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Update Poetry lock on a regular basis
2+
3+
on:
4+
schedule:
5+
- cron: '0 4 * * 0' # weekly at 04:00 on Sunday -> https://crontab.guru/#0_4_*_*_0
6+
workflow_dispatch:
7+
8+
env:
9+
# Versions are also listed in PR.yml
10+
POETRY_VERSION: 1.2.2
11+
PYTHON_VERSION: 3.9 # Use latest
12+
13+
jobs:
14+
org-check:
15+
name: Check GitHub Organization
16+
if: github.repository_owner == 'ni'
17+
runs-on: ubuntu-20.04
18+
steps:
19+
- name: Noop
20+
run: "true"
21+
update_poetry_lock:
22+
name: Update Poetry Lock
23+
runs-on: ubuntu-latest
24+
needs: org-check
25+
steps:
26+
- uses: actions/checkout@v2
27+
with:
28+
ref: main # This is the branch the PR is to be created from
29+
persist-credentials: true # make the token that is used the GITHUB_TOKEN, instead of your personal token
30+
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
31+
- name: Store vars
32+
id: vars
33+
run: |
34+
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
35+
echo "branch_name=automated-updates/update-poetry-lock" >> $GITHUB_OUTPUT
36+
- name: Create branch
37+
run: git checkout -b ${{ steps.vars.outputs.branch_name }}
38+
- uses: actions/setup-python@v2
39+
with:
40+
python-version: ${{ env.PYTHON_VERSION }}
41+
- uses: Gr1N/setup-poetry@v8
42+
with:
43+
poetry-version: ${{ env.POETRY_VERSION }}
44+
- name: Configure git user
45+
# https://github.com/actions/checkout/discussions/479
46+
run: |
47+
git config user.name "github-actions[bot]"
48+
git config user.email "github-actions[bot]@users.noreply.github.com"
49+
- name: Check for lock changes
50+
run: |
51+
poetry lock
52+
git commit -am "Update poetry lock file" || exit 0
53+
poetry install
54+
poetry run ni-python-styleguide fix
55+
git commit -am "Update formatting" || true
56+
git push --force --set-upstream origin ${{ steps.vars.outputs.branch_name }}
57+
# based on https://stackoverflow.com/a/73340290/8100990
58+
- name: Create Pull Request
59+
run: |
60+
gh pr create -B main -H ${{ steps.vars.outputs.branch_name }} --title 'Update poetry lock and reformat' --body '# Update Poetry Lock
61+
62+
Ran:
63+
* `poetry lock`,
64+
* `poetry install`, then
65+
* `ni-python-styleguide fix` to reformat any changes.
66+
67+
\-\-\-
68+
Created by Github action'
69+
env:
70+
GH_TOKEN: ${{ secrets.ADMIN_PAT }}

0 commit comments

Comments
 (0)