Skip to content
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

Migrate to copier template for pre-commit-mirrors #18

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file is managed by Copier; DO NOT EDIT OR REMOVE.
_commit: v0.1.7
_src_path: git@github.com:quantco/copier-template-pre-commit-mirrors
conda_package: insert-license-header
description: This pre-commit hook automatically inserts our license header at the
beginning of source code files tracked by Git.
entry: insert-license --license-base64 Q29weXJpZ2h0IChjKSBRdWFudENvIHt5ZWFyX3N0YXJ0fS17eWVhcl9lbmR9ClNQRFgtTGljZW5zZS1JZGVudGlmaWVyOiBMaWNlbnNlUmVmLVF1YW50Q28K
tool: insert-license-header
url: https://github.com/thomasmarwitz/insert-license-header
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @Quantco/ci
* @quantco/ci
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
interval: monthly
reviewers:
- quantco/ci
groups:
dependencies:
patterns:
- "*"
- "*"
11 changes: 5 additions & 6 deletions .github/workflows/autoupdate.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Autoupdate

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
- cron: "0 0 * * 0"

defaults:
run:
Expand All @@ -16,8 +17,6 @@ jobs:
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Set up Conda env
uses: mamba-org/setup-micromamba@8767fb704bd78032e9392f0386bf46950bdd1194
with:
Expand All @@ -32,8 +31,8 @@ jobs:
new_version=$(micromamba list -n check-env "$pkgname" --json | jq -r '.[0].version')
if [[ "$new_version" != "$old_version" ]]; then
sed -i "s/$old_version/$new_version/g" environment.yml
echo "pkgname=$pkgname" >> "$GITHUB_OUTPUT"
echo "new-version=$new_version" >> "$GITHUB_OUTPUT"
echo "pkgname=$pkgname" >> $GITHUB_OUTPUT
echo "new-version=$new_version" >> $GITHUB_OUTPUT
fi
- uses: peter-evans/create-pull-request@b1ddad2c994a25fbc81a28b3ec0e368bb2021c50
if: steps.versions.outputs.pkgname
Expand All @@ -45,4 +44,4 @@ jobs:

This PR updates ${{ steps.versions.outputs.pkgname }} to version ${{ steps.versions.outputs.new-version }} and will push a tag on merge automatically.
branch: v${{ steps.versions.outputs.new-version }}
delete-branch: true
delete-branch: true
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
- name: Check 'insert-license' executable is available
run: |
insert-license --help
shell: bash -l {0}
shell: bash -l {0}
20 changes: 10 additions & 10 deletions .github/workflows/keep-alive.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: Keep Repository Active
name: Keep
on:
schedule:
- cron: "0 6 * * SUN" # Once weekly on Sunday @ 0600 UTC
- cron: 0 6 * * SUN

jobs:
keep-alive: # Prevent cron jobs (in 'autoupdate.yml') from being suspended due to inactive repository
keep-alive:
name: Alive
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gautamkrishnar/keepalive-workflow@5b3128727d02fe1a892d0a2987517c9ec8ca7425
with:
commit_message: "Ah ah ah, stayin' alive"
committer_username: ForrestQuant
committer_email: "forrestquant@users.noreply.github.com"
time_elapsed: 50 # days
- uses: actions/checkout@v4
- uses: gautamkrishnar/keepalive-workflow@5b3128727d02fe1a892d0a2987517c9ec8ca7425
with:
commit_message: Ah ah ah, stayin' alive
committer_username: ForrestQuant
committer_email: forrestquant@users.noreply.github.com
time_elapsed: 50 # days
4 changes: 1 addition & 3 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: Quantco/ui-actions/version-metadata@v1
id: version-metadata
with:
Expand All @@ -23,4 +21,4 @@ jobs:
run: |
version="${{ steps.version-metadata.outputs.newVersion }}"
git tag "$version"
git push origin "$version"
git push origin "$version"
11 changes: 5 additions & 6 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
- id: insert-license
name: Insert license in comments
description: "Insert a short license disclaimer as a header comment in source files"
entry: insert-license --license-base64 Q29weXJpZ2h0IChjKSBRdWFudENvIHt5ZWFyX3N0YXJ0fS17eWVhcl9lbmR9ClNQRFgtTGljZW5zZS1JZGVudGlmaWVyOiBMaWNlbnNlUmVmLVF1YW50Q28K
language: conda
types: [text]
- id: insert-license
name: insert-license-header-conda
description: 'This pre-commit hook automatically inserts our license header at the beginning of source code files tracked by Git.'
entry: insert-license --license-base64 Q29weXJpZ2h0IChjKSBRdWFudENvIHt5ZWFyX3N0YXJ0fS17eWVhcl9lbmR9ClNQRFgtTGljZW5zZS1JZGVudGlmaWVyOiBMaWNlbnNlUmVmLVF1YW50Q28K
language: conda
4 changes: 2 additions & 2 deletions LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2023 QuantCo, Inc.
Copyright 2024 QuantCo, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Expand All @@ -8,4 +8,4 @@ Redistribution and use in source and binary forms, with or without modification,

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
## insert-license-header (-conda) mirror
# insert-license-header pre-commit hook

> [!NOTE]
> To follow our pre-commit hook mirror convention, this repo has been rename: `pre-commit-insert-license` => `pre-commit-mirrors-insert-license`.
pre-commit hook of insert-license-header with conda as a `language` / package manager.

This pre-commit hook automatically inserts our license header at the beginning of source code files tracked by Git.
For pre-commit: see [here](https://github.com/pre-commit/pre-commit)

Usage: (in `.pre-commit-config.yaml`)
For insert-license-header: see [here](https://github.com/thomasmarwitz/insert-license-header)

```
repos:
- repo: https://github.com/Quantco/pre-commit-mirrors-insert-license
rev: "1.1.0"
hooks:
- id: insert-license
types: [python]
args:
- --dynamic-years
- --comment-style
- "#"
## Using insert-license-header with pre-commit and conda:

Add this to your `.pre-commit-config.yaml`

```yaml
- repo: https://github.com/quantco/pre-commit-mirrors-insert-license-header
rev: '' # Use the sha / tag you want to point at
hooks:
- id: insert-license-header-conda
```

> [!WARNING]
Expand Down Expand Up @@ -52,3 +49,4 @@ To remove all license headers, temporarily add the `--remove-header` arg in
your `.pre-commit-config.yaml`. Run the hook on all files: `pre-commit run insert-license -a`.

For more configuration options see the conda-packaged tool [insert-license-header](https://github.com/thomasmarwitz/insert-license-header) that exposes the `insert-license-header` executable, the original repository [Lucas-C/pre-commit-hooks](https://github.com/Lucas-C/pre-commit-hooks) and [Pre-Commit](https://pre-commit.com/).

1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
channels:
- conda-forge
- nodefaults
dependencies:
- insert-license-header=1.3.0