-
-
Notifications
You must be signed in to change notification settings - Fork 378
Adding Github action to regenerate Lockfile #1506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # https://docs.github.com/en/actions/using-workflows/reusing-workflows#calling-a-reusable-workflow | ||
| # https://docs.github.com/fr/actions/using-workflows/workflow-syntax-for-github-actions#exemple--inclusion-de-chemins-dacc%C3%A8s | ||
|
|
||
| name: Lock dependencies | ||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize, labeled, unlabeled] | ||
| workflow_dispatch: | ||
| # Concurrency : auto-cancel "old" jobs ie when pushing again | ||
| # https://docs.github.com/fr/actions/using-jobs/using-concurrency | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | ||
| cancel-in-progress: true | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| permissions: | ||
| pull-requests: write | ||
| contents: write | ||
|
|
||
| jobs: | ||
| lock-deps: | ||
| if: ${{ !github.event.pull_request || contains( github.event.pull_request.labels.*.name, 'Lockfile') }} | ||
| name: "Lock dependencies using PDM" | ||
| runs-on: ubuntu-latest | ||
| continue-on-error: false # https://ncorti.com/blog/howto-github-actions-build-matrix | ||
| steps: | ||
| - name: Check if organization member | ||
| id: is_organization_member | ||
| uses: JamesSingleton/[email protected] | ||
| with: | ||
| organization: Giskard-AI | ||
| username: ${{ github.actor }} | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Interrupt job | ||
| if: ${{ steps.is_organization_member.outputs.result == 'false' }} | ||
| shell: bash | ||
| run: | | ||
| echo "Job failed due to user not being a member of Giskard-AI organization and the 'safe for build' label not being set on the PR" | ||
| exit 1 | ||
|
|
||
| - name: Extract branch name | ||
| shell: bash | ||
| run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | ||
| id: extract_branch | ||
|
|
||
| - name: Checkout code | ||
| uses: actions/[email protected] | ||
| with: | ||
| token: ${{ secrets.RELEASE_PAT_TOKEN }} # Needed to trigger other actions | ||
| ref: ${{ steps.extract_branch.outputs.branch }} | ||
|
|
||
| - name: Setup PDM | ||
| uses: pdm-project/setup-pdm@v3 | ||
| with: | ||
| python-version: "3.10" | ||
| cache: false | ||
|
|
||
| - name: Install dependencies | ||
| run: rm -rf pdm.lock && pdm lock -G :all | ||
|
|
||
| - name: Configure git | ||
| run: | | ||
| git config --global user.name 'BotLocker' | ||
| git config --global user.email '[email protected]' | ||
|
|
||
| - name: Adding file | ||
| run: | | ||
| git add pdm.lock | ||
| git commit -m "Regenerating pdm.lock" --allow-empty | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like it's fine to get an empty commit if the lock is already up to date, to show it's been regenerating either way |
||
|
|
||
| - name: Remove label | ||
| if: ${{ github.event.pull_request}} | ||
| run: | | ||
| gh pr edit --remove-label Lockfile | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
|
|
||
| - name: Push to target branch | ||
| run: | | ||
| git push origin ${{ steps.extract_branch.outputs.branch }} | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be
paths:pointing to pyproject.toml, no?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was basing it on a label, to regenerate the lockfile only on demand, either on PR, or by running the action.