Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
Imrpove dev env
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jun 16, 2023
1 parent aaf7a39 commit 5b6c790
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 23 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci-go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
- run: go build -v
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
- name: lint
run: go vet
- name: format
run: go fmt && git add --intent-to-add . && git diff --exit-code
20 changes: 0 additions & 20 deletions .github/workflows/ci.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Dependency Review'
on:
pull_request:
paths:
- '.github/workflows/**'
- '**.nix'
- 'go.mod'
- 'go.sum'

permissions:
contents: read

jobs:
dependency-review:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
- name: 'Dependency Review'
uses: actions/dependency-review-action@v3
with:
# https://spdx.org/licenses/
allow-licenses: MIT, BSD-3-Clause, BSD-2-Clause, 0BSD, Unlicense, ISC, Apache-2.0, CC-BY-4.0
12 changes: 12 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint
on:
push:
branches: [main]
pull_request:
jobs:
dprint:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dprint/check@v2.2
57 changes: 57 additions & 0 deletions .github/workflows/merge-bot-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Merge bot PR after CI
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-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.5.1
- uses: actions/checkout@v3
- name: Wait other jobs
if: ${{steps.metadata.outputs.update-type != 'version-update:semver-major'}}
uses: kachick/wait-other-jobs@v1.2.1
timeout-minutes: 10
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
- name: Approve and merge
if: ${{steps.metadata.outputs.update-type != 'version-update:semver-major'}}
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-latest
if: ${{ github.actor == 'renovate[bot]' }}
steps:
- uses: actions/checkout@v3
- name: Wait other jobs
uses: kachick/wait-other-jobs@v1.2.1
timeout-minutes: 10
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
retry-method: 'equal_intervals'
min-interval-seconds: '15'
- 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}}
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"recommendations": [
"golang.go",
"redhat.vscode-yaml",
"editorconfig.editorconfig",
"streetsidesoftware.code-spell-checker",
"dprint.dprint",
"jnoortheen.nix-ide"
]
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
"editor.defaultFormatter": "dprint.dprint",
"editor.formatOnSave": true,
"[nix]": {
"editor.defaultFormatter": "jnoortheen.nix-ide"
},
"[go]": {
"editor.defaultFormatter": "golang.go"
},
"cSpell.words": [
"cachix",
"dprint",
"nixos",
"nixpkgs"
]
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ When I want to bump it, I always visit the nixpkgs repository and copy and paste

## NOTE

* I guess there are many other syntax patterns in Nix files that I have not used. This code will not care about them.
* I don't know [nix-community/go-nix](https://github.com/nix-community/go-nix) will fit or not.
* I don't know if Nix provides this feature with the CLI or not.
- I guess there are many other syntax patterns in Nix files that I have not used. This code will not care about them.
- I don't know [nix-community/go-nix](https://github.com/nix-community/go-nix) will fit or not.
- I don't know if Nix provides this feature with the CLI or not.
14 changes: 14 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"json": {},
"markdown": {},
"prettier": {
"printWidth": 120,
"singleQuote": true
},
"includes": ["**/*.{json,md,yml}"],
"plugins": [
"https://plugins.dprint.dev/json-0.17.1.wasm",
"https://plugins.dprint.dev/markdown-0.15.2.wasm",
"https://plugins.dprint.dev/prettier-0.24.0.json@9a57d0d8e440ad90d07a503166af47e7a6a886abd46767933f9c279f72468596"
]
}

0 comments on commit 5b6c790

Please sign in to comment.