Skip to content

Commit

Permalink
cherry-pick updates to relase tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
mshafer-NI committed Oct 9, 2023
1 parent d0b5083 commit 21f4035
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 23 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/Comment-on-PR.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
on:
pull_request_target:
paths:
- '*'
- '!docs/Coding-Conventions.md'
paths-ignore:
- "docs/Coding-Conventions.md"
types:
- opened
- reopened

jobs:
comment_on_pr:
Expand All @@ -11,7 +13,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Comment on PR
uses: thollander/actions-comment-pull-request@v1
with:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/Notify-Convention-Change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
pull_request_target:
paths:
- docs/Coding-Conventions.md
types:
- opened
- reopened

jobs:
org-check:
Expand All @@ -26,7 +29,6 @@ jobs:
Since this changes the Coding Conventions, I'll @-mention the appropriate NI engineers.
@alejandro5042
@alexweav
@DavidCurtiss
@irwand
@jryckman
Expand Down
14 changes: 5 additions & 9 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- .github/workflows/PR.yml

env:
POETRY_VERSION: 1.1.6
POETRY_VERSION: 1.2.2

jobs:
checks:
Expand All @@ -24,18 +24,14 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: Gr1N/setup-poetry@v4
- uses: Gr1N/setup-poetry@v8
with:
poetry-version: ${{ env.POETRY_VERSION }}
# @TODO: This is a workaround for there not being a way to check the lock file
# See: https://github.com/python-poetry/poetry/issues/453
- name: Check for lock changes
run: |
PYTHONPATH="${PYTHONPATH}:${HOME}/.poetry/lib:${HOME}/.poetry/lib/poetry/_vendor/py${{ env.PYTHON_VERSION }}" \
python -c "from poetry.factory import Factory; \
locker = Factory().create_poetry('.').locker; \
exit(0) if locker.is_locked() and locker.is_fresh() else exit(1)" \
&& echo 'OK'
poetry lock --check
- uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
Expand All @@ -50,14 +46,14 @@ jobs:
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- uses: Gr1N/setup-poetry@v4
- uses: Gr1N/setup-poetry@v8
with:
poetry-version: ${{ env.POETRY_VERSION }}
- uses: actions/cache@v2
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/Publish-Package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

env:
# Versions are also listed in PR.yml
POETRY_VERSION: 1.1.6
POETRY_VERSION: 1.2.2
PYTHON_VERSION: 3.9 # Use latest

jobs:
Expand All @@ -23,18 +23,14 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: Gr1N/setup-poetry@v4
- uses: Gr1N/setup-poetry@v8
with:
poetry-version: ${{ env.POETRY_VERSION }}
# @TODO: This is a workaround for there not being a way to check the lock file
# See: https://github.com/python-poetry/poetry/issues/453
- name: Check for lock changes
run: |
PYTHONPATH="${PYTHONPATH}:${HOME}/.poetry/lib:${HOME}/.poetry/lib/poetry/_vendor/py${{ env.PYTHON_VERSION }}" \
python -c "from poetry.factory import Factory; \
locker = Factory().create_poetry('.').locker; \
exit(0) if locker.is_locked() and locker.is_fresh() else exit(1)" \
&& echo 'OK'
poetry lock --check
- uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
Expand Down Expand Up @@ -71,7 +67,8 @@ jobs:
- name: Push changes
if: ${{ github.event.release.target_commitish == 'main' }}
uses: ad-m/github-push-action@master
uses: CasperWA/push-protected@v2
with:
github_token: ${{ secrets.ADMIN_PAT }}
token: ${{ secrets.ADMIN_PAT }}
branch: ${{ github.event.release.target_commitish }}
unprotect_reviews: true
70 changes: 70 additions & 0 deletions .github/workflows/Update-Poetry-Lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Update Poetry lock on a regular basis

on:
schedule:
- cron: '0 4 * * 0' # weekly at 04:00 on Sunday -> https://crontab.guru/#0_4_*_*_0
workflow_dispatch:

env:
# Versions are also listed in PR.yml
POETRY_VERSION: 1.2.2
PYTHON_VERSION: 3.9 # Use latest

jobs:
org-check:
name: Check GitHub Organization
if: github.repository_owner == 'ni'
runs-on: ubuntu-20.04
steps:
- name: Noop
run: "true"
update_poetry_lock:
name: Update Poetry Lock
runs-on: ubuntu-latest
needs: org-check
steps:
- uses: actions/checkout@v2
with:
ref: main # This is the branch the PR is to be created from
persist-credentials: true # make the token that is used the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: Store vars
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "branch_name=automated-updates/update-poetry-lock" >> $GITHUB_OUTPUT
- name: Create branch
run: git checkout -b ${{ steps.vars.outputs.branch_name }}
- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: Gr1N/setup-poetry@v8
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Configure git user
# https://github.com/actions/checkout/discussions/479
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Check for lock changes
run: |
poetry lock
git commit -am "Update poetry lock file" || exit 0
poetry install
poetry run ni-python-styleguide fix
git commit -am "Update formatting" || true
git push --force --set-upstream origin ${{ steps.vars.outputs.branch_name }}
# based on https://stackoverflow.com/a/73340290/8100990
- name: Create Pull Request
run: |
gh pr create -B main -H ${{ steps.vars.outputs.branch_name }} --title 'Update poetry lock and reformat' --body '# Update Poetry Lock
Ran:
* `poetry lock`,
* `poetry install`, then
* `ni-python-styleguide fix` to reformat any changes.
\-\-\-
Created by Github action'
env:
GH_TOKEN: ${{ secrets.ADMIN_PAT }}

0 comments on commit 21f4035

Please sign in to comment.