Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw committed May 22, 2024
0 parents commit c5e2670
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file is managed by Copier; DO NOT EDIT OR REMOVE.
_commit: v0.1.9-16-g2ebc061
_src_path: [email protected]:quantco/copier-template-pre-commit-mirrors
conda_package: taplo
description: 'A TOML toolkit written in Rust'
entry: taplo format
tool: taplo
url: https://github.com/tamasfe/taplo
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @quantco/ci
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE/issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: New issue
about: Create a new issue
---

<!-- ⚠️ This is an open-source repository. Do not share sensitive information. -->
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- ⚠️ This is an open-source repository. Do not share sensitive information. -->
47 changes: 47 additions & 0 deletions .github/workflows/autoupdate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Autoupdate

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

defaults:
run:
shell:
bash -el {0}

jobs:
check_update:
name: Check if newer version exists
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Set up Conda env
uses: mamba-org/setup-micromamba@422500192359a097648154e8db4e39bdb6c6eed7
with:
environment-file: environment.yml
environment-name: check-env
- name: Find latest version
id: versions
run: |
pkgname="$(yq '.dependencies[0]' environment.yml | grep -Eio '[a-z0-9_-]+' | head -n 1)"
old_version=$(micromamba list -n check-env "$pkgname" --json | jq -r '.[0].version')
micromamba update -y -n check-env -a
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
fi
- uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e
if: steps.versions.outputs.pkgname
with:
commit-message: "Update ${{ steps.versions.outputs.pkgname }} to ${{ steps.versions.outputs.new-version }}"
title: "Update ${{ steps.versions.outputs.pkgname }} to ${{ steps.versions.outputs.new-version }}"
body: |
A new release of ${{ steps.versions.outputs.pkgname }} was detected on conda-forge.
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
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
pre-commit-checks:
name: Pre-commit Checks
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Run pre-commit-conda
uses: quantco/pre-commit-conda@v1
env:
name: Test env
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Set up Conda env
uses: mamba-org/setup-micromamba@422500192359a097648154e8db4e39bdb6c6eed7
with:
environment-file: environment.yml
environment-name: test-env
14 changes: 14 additions & 0 deletions .github/workflows/keep-alive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Keep
on:
schedule:
- cron: 0 6 * * SUN

jobs:
keep-alive:
name: Alive
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: actions/checkout@v4
- uses: gautamkrishnar/keepalive-workflow@7fa96d25d8e4c2811d5405d6328111f1ef548246
24 changes: 24 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Tag on version bump

on:
push:
branches:
- main

jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Quantco/ui-actions/version-metadata@v1
id: version-metadata
with:
file: environment.yml
token: ${{ secrets.GITHUB_TOKEN }}
version-extraction-override: 'regex:\s+- taplo=(\d+.\d+.\d+)'
- name: Bump tag
if: steps.version-metadata.outputs.changed == 'true'
run: |
version="${{ steps.version-metadata.outputs.newVersion }}"
git tag "$version"
git push origin "$version"
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
exclude: ^\.copier-answers\.yml$
repos:
- repo: https://github.com/Quantco/pre-commit-mirrors-pre-commit-hooks
rev: 4.5.0
hooks:
- id: trailing-whitespace-conda
- id: end-of-file-fixer-conda
- id: check-merge-conflict-conda
args: ["--assume-in-merge"]
5 changes: 5 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- id: taplo-conda
name: taplo-conda
description: 'A TOML toolkit written in Rust'
entry: taplo format
language: conda
11 changes: 11 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

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.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# taplo pre-commit hook

pre-commit hook of taplo with conda as a `language` / package manager.

For pre-commit: see [here](https://github.com/pre-commit/pre-commit)

For taplo: see [here](https://github.com/tamasfe/taplo)

## Using taplo with pre-commit and conda:

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

```yaml
- repo: https://github.com/quantco/pre-commit-mirrors-taplo
rev: '' # Use the sha / tag you want to point at
hooks:
- id: taplo-conda
```
5 changes: 5 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
channels:
- conda-forge
- nodefaults
dependencies:
- taplo=0.9.1

0 comments on commit c5e2670

Please sign in to comment.