-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dcef678
Showing
25 changed files
with
3,783 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# GitHub syntax highlighting | ||
pixi.lock linguist-language=YAML | ||
|
Validating CODEOWNERS rules …
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 @@ | ||
* @quantco/ci |
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,26 @@ | ||
version: 2 | ||
registries: | ||
github: | ||
type: git | ||
url: https://github.com | ||
username: x-access-token | ||
password: ${{ secrets.DEPENDABOT_CONTENT_PAT }} | ||
updates: | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: daily | ||
registries: | ||
- github | ||
groups: | ||
dependencies: | ||
patterns: | ||
- "*" | ||
- package-ecosystem: github-actions | ||
directory: /template/.github/workflows | ||
schedule: | ||
interval: daily | ||
groups: | ||
dependencies: | ||
patterns: | ||
- "*" |
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,92 @@ | ||
name: Bump versions | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: 0 6 * * * | ||
|
||
jobs: | ||
generate-tools: | ||
name: Get all tools | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.setmatrix.outputs.matrix }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get all tools | ||
id: setmatrix | ||
shell: python | ||
run: | | ||
import os | ||
import json | ||
from pathlib import Path | ||
tools = {} | ||
# incompatible with subdirectory actions | ||
skip_actions = ["Quantco/ui-actions/version-metadata"] | ||
for file in Path("template/.github/workflows").glob("*"): | ||
content = file.read_text() | ||
# go over every `uses: ` line | ||
for line in content.splitlines(): | ||
if "uses: " in line: | ||
# extract the action name | ||
action, version = line.split("uses: ", 1)[1].split("@", 1) | ||
if action in skip_actions: | ||
# not possible because it's a private repository | ||
continue | ||
tools[action] = ("major" if version.startswith("v") else "sha") | ||
matrix = [] | ||
for tool, versioning in tools.items(): | ||
matrix.append({"tool": tool, "versioning": versioning}) | ||
with open(os.environ["GITHUB_OUTPUT"], "w") as f: | ||
f.write(f"matrix={json.dumps(matrix)}") | ||
bump: | ||
needs: [generate-tools] | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: ${{ fromJson(needs.generate-tools.outputs.matrix) }} | ||
name: Bump ${{ matrix.tool }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
# needed s.t. the workflows have permissions to run when the PR is created | ||
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
ref: ${{ github.head_ref }} | ||
- name: Bump versions | ||
id: bump | ||
run: | | ||
set -exuo pipefail | ||
new_version="$(gh repo view --json latestRelease ${{ matrix.tool }} | jq -r '.latestRelease.tagName')" | ||
if [[ ${{ matrix.versioning }} = "sha" ]]; then | ||
echo "new-version=$new_version" >> "$GITHUB_OUTPUT" | ||
commit_sha="$(gh api "repos/${{ matrix.tool }}/commits/$new_version" | jq -r '.sha')" | ||
for file in ./template/.github/workflows/*; do | ||
sed -i -e "s#${{ matrix.tool }}@.*#${{ matrix.tool }}@${commit_sha}#g" "$file" | ||
done | ||
elif [[ ${{ matrix.versioning }} = "major" ]]; then | ||
new_version_major="$(echo "$new_version" | cut -d. -f1)" | ||
echo "new-version=$new_version_major" >> "$GITHUB_OUTPUT" | ||
for file in ./template/.github/workflows/*; do | ||
sed -i -e "s#${{ matrix.tool }}@.*#${{ matrix.tool }}@${new_version_major}#g" "$file" | ||
done | ||
else | ||
echo "Unknown versioning scheme: ${{ matrix.versioning }}" | ||
exit 1 | ||
fi | ||
git diff | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 | ||
with: | ||
title: Bump ${{ matrix.tool }} to ${{ steps.bump.outputs.new-version }} | ||
delete-branch: true | ||
commit-message: Bump ${{ matrix.tool }} version to ${{ steps.bump.outputs.new-version }} | ||
branch: bump-${{ matrix.tool }}-${{ steps.bump.outputs.new-version }} | ||
labels: dependencies |
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,26 @@ | ||
name: CI Copier | ||
on: [push] | ||
|
||
# Automatically stop old builds on the same branch/PR | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
linux-unittests: | ||
name: Check project generation | ||
timeout-minutes: 30 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # copier doesn't like shallow clones | ||
- name: Set up pixi | ||
uses: prefix-dev/setup-pixi@ca3b9ac762955fad216e3d8e0bbf22087071c89c | ||
- name: Run unittests | ||
uses: quantco/pytest-action@v2 | ||
with: | ||
report-title: Check project generation | ||
click-to-expand: false | ||
custom-pytest: pixi run pytest |
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,4 @@ | ||
# pixi environments | ||
.pixi | ||
|
||
__pycache__ |
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,9 @@ | ||
# copier-template-pre-commit-mirrors | ||
|
||
This is a template for our pre-commit mirrors. | ||
|
||
To create a new mirror, you can run the following command | ||
|
||
```bash | ||
pixi run generate /path/to/mirror | ||
``` |
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 @@ | ||
# configuration | ||
_subdirectory: template | ||
_min_copier_version: '9.1.1' | ||
|
||
# questions | ||
tool: | ||
type: str | ||
help: What is the name of the tool? | ||
validator: >- | ||
{% if entry == '' %} | ||
Please provide a valid tool name | ||
{% endif %} | ||
url: | ||
type: str | ||
help: What is the URL of the tool? | ||
validator: >- | ||
{% if not url.startswith('https://') %} | ||
Please provide a URL | ||
{% endif %} | ||
entry: | ||
type: str | ||
help: What is the pre-commit entry (for example `ruff --fix --exit-non-zero-on-fix`)? | ||
validator: >- | ||
{% if entry == '' %} | ||
Please provide an entry | ||
{% endif %} | ||
_tasks: | ||
- sed -i "s/TOOL_VERSION/$(micromamba search -c conda-forge {{ tool }} --json | jq -r '.result.pkgs[0].version')/g" environment.yml | ||
- git init | ||
- git branch -M main |
Oops, something went wrong.