Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick authored Mar 14, 2024
0 parents commit e8f0d15
Show file tree
Hide file tree
Showing 19 changed files with 436 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
root = true

[*]
end_of_line = lf
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[{Makefile,*.mk,go.mod,go.sum,*.go,.gitmodules,*.sh,*.dash,*.bash,*.zsh}]
indent_style = tab
indent_size = 4

[*.rs]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4

[*.{hs,lhs}]
indent_style = space
indent_size = 4
max_line_length = 80

[*.elm]
indent_style = space
indent_size = 4
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

use flake
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.envrc linguist-vendored
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'weekly'
ignore:
- dependency-name: 'crate-ci/typos'
groups:
DeterminateSystems-actions:
patterns:
- 'DeterminateSystems*'
23 changes: 23 additions & 0 deletions .github/workflows/bump-flake-lock-and-selfup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 🤖🆙❄️
on:
pull_request:
paths:
- '.github/workflows/bump-flake-lock-and-selfup.yml'
schedule:
# At 10:17 JST on day-of-month 1 and on Monday.
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
# You can understand the config actually say what in https://crontab.guru/
- cron: '17 1 1 * 1'
workflow_dispatch:

jobs:
bump:
uses: kachick/selfup/.github/workflows/reusable-bump-flake-lock-and-selfup.yml@action-v1
with:
dry-run: ${{ github.event_name == 'pull_request' }}
pr-title: 'Bump flake.lock and related dependencies'
optional-run: |
echo 'Add another changes and git commit here, especially for .node-version/.ruby-version'
secrets:
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
41 changes: 41 additions & 0 deletions .github/workflows/ci-nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# https://github.com/NixOS/nixos-artwork/blob/35ebbbf01c3119005ed180726c388a01d4d1100c/logo/README.md#L5
name: ❄️
on:
push:
branches: [main]
paths:
- '.github/workflows/ci-nix.yml'
- '*.nix'
- 'flake.*'
- 'Taskfile.yml'
pull_request:
paths:
- '.github/workflows/ci-nix.yml'
- '*.nix'
- 'flake.*'
- 'Taskfile.yml'
schedule:
# Every 10:42 JST
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: '42 1 * * *'
workflow_dispatch:

jobs:
tasks:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- macos-14
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v10
- uses: DeterminateSystems/magic-nix-cache-action@v4
- run: nix flake check
- run: nix develop --command echo 'This step should be done before any other "nix develop" steps because of measuring Nix build time'
- run: nix develop --command task deps
- run: nix develop --command task check
# - run: nix run . -- --version
20 changes: 20 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 💂➕
on:
pull_request:

permissions:
contents: read

jobs:
dependency-review:
timeout-minutes: 15
runs-on: ubuntu-22.04
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v4
with:
# https://spdx.org/licenses/
allow-licenses: MIT, BSD-3-Clause, BSD-2-Clause, 0BSD, Unlicense, ISC, Apache-2.0, CC-BY-4.0
allow-dependencies-licenses: pkg:githubactions/DeterminateSystems/nix-installer-action
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 👕
on:
push:
branches: [main]
pull_request:
workflow_dispatch:

jobs:
dprint:
timeout-minutes: 15
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dprint/check@v2.2
with:
dprint-version: '0.45.0' # selfup { "regex": "\\d[^']+", "script": "dprint --version | cut -d ' ' -f 2" }

typos:
timeout-minutes: 15
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@v1.19.0 # selfup { "regex": "\\d\\.\\d+\\.\\d+", "script": "typos --version | cut -d ' ' -f 2" }
with:
files: |
.
.github
.vscode
64 changes: 64 additions & 0 deletions .github/workflows/merge-bot-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: 🤖👌🤖
on: pull_request

permissions:
contents: write
pull-requests: write
# checks: read # For private repositories
# actions: read # For private repositories

jobs:
dependabot:
timeout-minutes: 30
runs-on: ubuntu-22.04
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.6.0
- name: Wait other jobs
if: ${{ steps.metadata.outputs.update-type != 'version-update:semver-major' }}
uses: kachick/wait-other-jobs@v2.0.3
timeout-minutes: 10
- name: Approve and merge
if: ${{ steps.metadata.outputs.update-type != 'version-update:semver-major' || contains(steps.metadata.outputs.dependency-names, 'DeterminateSystems') }}
run: gh pr review --approve "$PR_URL" && gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Avoid `automerge` renovate official feature.
# It wait longtime to be merged.
# Avoid `platformAutomerge` renovate official feature.
# It requires many changes in GitHub settings.
# - `Allow auto-merge`
# - `Require status checks to pass before merging` and specify the status names
# Changing in all personal repository is annoy task for me. Even if using terrafform, getting mandatory CI names in each repo is too annoy!
renovate:
timeout-minutes: 30
runs-on: ubuntu-22.04
if: ${{ github.actor == 'renovate[bot]' }}
steps:
- name: Wait other jobs
uses: kachick/wait-other-jobs@v2.0.3
timeout-minutes: 10
- name: Approve and merge
run: gh pr review --approve "$PR_URL" && gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# https://github.com/kachick/anylang-template/issues/51
selfup-runner:
timeout-minutes: 30
runs-on: ubuntu-22.04
if: ${{ github.actor == 'selfup-runner[bot]' }}
steps:
- name: Wait other jobs
uses: kachick/wait-other-jobs@v2.0.3
timeout-minutes: 20
- name: Approve and merge
run: gh pr review --approve "$PR_URL" && gh pr merge --auto --delete-branch --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.direnv
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"github.vscode-github-actions",
"editorconfig.editorconfig",
"tekumara.typos-vscode",
"dprint.dprint",
"jnoortheen.nix-ide"
]
}
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"editor.defaultFormatter": "dprint.dprint",
"editor.formatOnSave": true,
"[nix]": {
"editor.defaultFormatter": "jnoortheen.nix-ide"
},
"nix.enableLanguageServer": true,
"nix.serverPath": "nil",
"nix.serverSettings": {
"nil": {
"formatting": {
"command": ["nixpkgs-fmt"]
}
}
}
}
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# How to develop

## Setup

1. Install [Nix](https://nixos.org/) package manager
2. Allow [Flakes](https://nixos.wiki/wiki/Flakes)
3. Run dev shell as one of the following
- with [direnv](https://github.com/direnv/direnv): `direnv allow`
- nix only: `nix develop`
4. You can use development tools

```console
> nix develop
(prepared bash)
> dprint --version
...
```
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Kenichi Kamiya

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# anylang-template

[![CI - Nix Status](https://github.com/kachick/anylang-template/actions/workflows/ci-nix.yml/badge.svg?branch=main)](https://github.com/kachick/anylang-template/actions/workflows/ci-nix.yml?query=branch%3Amain+)

A template that is not exclusive to one programming language.\
Basic setup for editor, documents and GitHub Actions.
33 changes: 33 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# https://taskfile.dev

version: '3'

tasks:
default:
deps:
- task: fmt
- task: lint
- task: test
check:
deps:
- task: test
- task: lint
test:
cmds:
- echo 'Update here'
fmt:
cmds:
- dprint fmt
- nixpkgs-fmt ./*.nix
lint:
cmds:
- dprint check
- typos . .github .vscode
- nixpkgs-fmt --check ./*.nix
deps:
cmds:
- nix --version
- nil --version
- task --version
- dprint --version
- typos --version
15 changes: 15 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"json": {
"trailingCommas": "never"
},
"markdown": {},
"prettier": {
"printWidth": 120,
"singleQuote": true
},
"plugins": [
"https://plugins.dprint.dev/json-0.19.2.wasm",
"https://plugins.dprint.dev/markdown-0.16.4.wasm",
"https://plugins.dprint.dev/prettier-0.39.0.json@896b70f29ef8213c1b0ba81a93cee9c2d4f39ac2194040313cd433906db7bc7c"
]
}
Loading

0 comments on commit e8f0d15

Please sign in to comment.