-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update cookiecutter to new standard via cruft (#319)
### What kind of change does this PR introduce? * Updates the cookiecutter with the newest conventions and workflows ### Does this PR introduce a breaking change? Boilerplate documentation is largely unchanged. Workflows are now more a bit more elegant, including automatic labelling, warnings about unsafe changes to workflows, security-related changes, etc. `actions-versions-updater.yml` has been replaced with `Dependabot` (it's just better). There's support for evaluating the OpenSSF Scorecard (this can be disabled if we want). Code formatting tools are now hard-pinned. These need to be kept in sync with changes from `pre-commit`. `Dependabot` should do this task automatically via Pull Requests. Versioning scheme is now SemVer 2.0-compliant: * If the version doesn't end in `-dev` or `-dev.##`, `$ bump-my-version bump patch` will be called. This will set the version at `X.Y.Z+1-dev`. Otherwise, `$ bump-my-version bump build` will be called. This is all automated by the `bump-version.yml`. When the version is ready for a release, it's up to the maintainer to call the following: * `$ bump-my-version bump release` (for a patch release; i.e. `1.2.0` → `1.2.1`) or * `$ bump-my-version bump minor` then `$ bump-my-version bump release` (for a minor release; i.e. `1.2.0` → `1.3.0`) There is now also support for Documentation locales (translations) via `.po` files. These can be staged with `$ make initialize-translations`, whereby `.po` files will be generated and French (or other) language strings can be added. * **I'm not sure how this will interact with existing translation code. Might be worth it to leave this deactivated** ### Other information: Ouranosinc/cookiecutter-pypackage#30
- Loading branch information
Showing
26 changed files
with
389 additions
and
104 deletions.
There are no files selected for viewing
This file contains 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
File renamed without changes.
This file contains 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,15 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: daily | ||
time: '12:00' | ||
open-pull-requests-limit: 10 | ||
|
||
- package-ecosystem: pip | ||
directory: / | ||
schedule: | ||
interval: daily | ||
time: '12:00' | ||
open-pull-requests-limit: 10 |
This file contains 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 |
---|---|---|
|
@@ -36,4 +36,4 @@ | |
'xclim': | ||
- changed_files: | ||
- any-glob-to-any-file: | ||
- 'scen/xclim_modules/**/*' | ||
- 'xscen/xclim_modules/**/*' |
This file contains 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
This file contains 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,47 @@ | ||
# Example taken from https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#managing-caches | ||
name: Cleanup Caches on Pull Request Merge | ||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
permissions: # added using https://github.com/step-security/secure-repo | ||
contents: read | ||
|
||
jobs: | ||
cleanup: | ||
name: Cleanup | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1 | ||
with: | ||
disable-sudo: true | ||
egress-policy: block | ||
allowed-endpoints: > | ||
api.github.com:443 | ||
github.com:443 | ||
objects.githubusercontent.com:443 | ||
- uses: actions/checkout@v4.1.1 | ||
|
||
- name: Cleanup | ||
run: | | ||
gh extension install actions/gh-actions-cache | ||
REPO=${{ github.repository }} | ||
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" | ||
echo "Fetching list of cache key" | ||
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) | ||
## Setting this to not fail the workflow while deleting cache keys. | ||
set +e | ||
echo "Deleting caches..." | ||
for cacheKey in $cacheKeysForPR | ||
do | ||
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm | ||
done | ||
echo "Done" | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains 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,31 @@ | ||
# Dependency Review Action | ||
# | ||
# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging. | ||
# | ||
# Source repository: https://github.com/actions/dependency-review-action | ||
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement | ||
name: 'Dependency Review' | ||
on: | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
dependency-review: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1 | ||
with: | ||
disable-sudo: true | ||
egress-policy: block | ||
allowed-endpoints: > | ||
api.github.com:443 | ||
github.com:443 | ||
- name: 'Checkout Repository' | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: 'Dependency Review' | ||
uses: actions/dependency-review-action@4901385134134e04cec5fbe5ddfe3b2c5bd5d976 |
This file contains 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
This file contains 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
This file contains 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,82 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by separate terms of service, privacy | ||
# policy, and support documentation. | ||
|
||
name: Scorecard supply-chain security | ||
on: | ||
# For Branch-Protection check. Only the default branch is supported. See | ||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection | ||
branch_protection_rule: | ||
# To guarantee Maintained check is occasionally updated. See | ||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained | ||
schedule: | ||
- cron: '41 8 * * 4' | ||
push: | ||
branches: | ||
- main | ||
|
||
# Declare default permissions as read only. | ||
permissions: read-all | ||
|
||
jobs: | ||
analysis: | ||
name: Scorecard analysis | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# Needed to upload the results to code-scanning dashboard. | ||
security-events: write | ||
# Needed to publish results and get a badge (see publish_results below). | ||
id-token: write | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1 | ||
with: | ||
disable-sudo: true | ||
egress-policy: block | ||
allowed-endpoints: > | ||
api.github.com:443 | ||
api.osv.dev:443 | ||
api.securityscorecards.dev:443 | ||
fulcio.sigstore.dev:443 | ||
github.com:443 | ||
oss-fuzz-build-logs.storage.googleapis.com:443 | ||
rekor.sigstore.dev:443 | ||
tuf-repo-cdn.sigstore.dev:443 | ||
www.bestpractices.dev:443 | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Run analysis | ||
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 | ||
with: | ||
results_file: results.sarif | ||
results_format: sarif | ||
# This job step requires a personal access token named `OPENSSF_SCORECARD_TOKEN` with the following privileges: | ||
# - Administration: Read-Only | ||
# - Metadata: Read-Only | ||
# - Webhooks: Read-Only | ||
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. | ||
repo_token: ${{ secrets.OPENSSF_SCORECARD_TOKEN }} | ||
|
||
# Public repositories: | ||
# - Publish results to OpenSSF REST API for easy access by consumers | ||
# - Allows the repository to include the Scorecard badge. | ||
# - See https://github.com/ossf/scorecard-action#publishing-results. | ||
publish_results: true | ||
|
||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF | ||
# format to the repository Actions tab. | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 | ||
with: | ||
name: SARIF file | ||
path: results.sarif | ||
retention-days: 5 | ||
|
||
# Upload the results to GitHub's code scanning dashboard. | ||
- name: Upload to code-scanning | ||
uses: github/codeql-action/upload-sarif@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # 3.23.0 | ||
with: | ||
sarif_file: results.sarif |
This file contains 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
This file contains 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,69 @@ | ||
name: Workflow Changes Warnings | ||
|
||
on: | ||
# Note: potential security risk from this action using pull_request_target. | ||
# Do not add actions in here which need a checkout of the repo, and do not use any caching in here. | ||
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target | ||
pull_request_target: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
paths: | ||
- .github/workflows/*.yml | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
comment-concerning-workflow-changes: | ||
name: Comment Concerning Workflow Changes | ||
runs-on: ubuntu-latest | ||
if: | | ||
(github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1 | ||
with: | ||
disable-sudo: true | ||
egress-policy: block | ||
allowed-endpoints: > | ||
api.github.com:443 | ||
- name: Find comment | ||
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # v2.4.0 | ||
id: fc | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: 'github-actions[bot]' | ||
body-includes: | | ||
This Pull Request modifies GitHub workflows and is coming from a fork. | ||
- name: Create comment | ||
if: | | ||
(steps.fc.outputs.comment-id == '') && | ||
(!contains(github.event.pull_request.labels.*.name, 'approved')) && | ||
(github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) | ||
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0 | ||
with: | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
> **Warning** | ||
> This Pull Request modifies GitHub Workflows and is coming from a fork. | ||
**It is very important for the reviewer to ensure that the workflow changes are appropriate.** | ||
edit-mode: replace | ||
- name: Update comment | ||
if: | | ||
contains(github.event.pull_request.labels.*.name, 'approved') | ||
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0 | ||
with: | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
> **Note** | ||
> Changes have been approved by a maintainer. | ||
reactions: | | ||
hooray | ||
edit-mode: append |
This file contains 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
This file contains 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
Oops, something went wrong.