fix: modified ci format action to work with forgejo and added treemfmt support
All checks were successful
ci / nix-fmt (push) Successful in 3m59s
All checks were successful
ci / nix-fmt (push) Successful in 3m59s
This commit is contained in:
parent
8eab69f026
commit
03b4acbc8b
4 changed files with 191 additions and 19 deletions
65
.forgejo/workflows/ci.yml
Executable file
65
.forgejo/workflows/ci.yml
Executable file
|
|
@ -0,0 +1,65 @@
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
USER: runner
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
nix-fmt:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: install nix
|
||||||
|
uses: https://github.com/cachix/install-nix-action@v31.8.4
|
||||||
|
with:
|
||||||
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
|
- name: set up nix
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.config/nix
|
||||||
|
echo "experimental-features = nix-command flakes pipe-operators" >> ~/.config/nix/nix.conf
|
||||||
|
nix-channel --add https://nixos.org/channels/nixos-unstable nixpkgs
|
||||||
|
nix-channel --update
|
||||||
|
- name: set up nix-community cachix
|
||||||
|
uses: https://github.com/cachix/cachix-action@v16
|
||||||
|
with:
|
||||||
|
name: nix-community
|
||||||
|
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||||
|
- name: setup git identity
|
||||||
|
run: |
|
||||||
|
git config --global user.name "forgejo-actions-bot"
|
||||||
|
git config --global user.email "actions@forgejo.local"
|
||||||
|
- name: import gpg key
|
||||||
|
env:
|
||||||
|
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||||
|
run: |
|
||||||
|
echo "$GPG_PRIVATE_KEY" | gpg --batch --import || true
|
||||||
|
KEYID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec/{print $5;exit}')
|
||||||
|
git config --global user.signingkey "$KEYID"
|
||||||
|
git config --global commit.gpgsign true
|
||||||
|
echo "default-cache-ttl 3600" >> ~/.gnupg/gpg-agent.conf
|
||||||
|
echo RELOADAGENT | gpg-connect-agent
|
||||||
|
- name: checkout code
|
||||||
|
uses: actions/checkout@v5.0.0
|
||||||
|
- name: run nix fmt
|
||||||
|
run: nix fmt
|
||||||
|
- name: check for changes
|
||||||
|
id: git_status
|
||||||
|
run: |
|
||||||
|
if [[ -n "$(git status --porcelain)" ]]; then
|
||||||
|
echo "changed=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "changed=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
- name: commit and push changes
|
||||||
|
if: steps.git_status.outputs.changed == 'true'
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.ACTIONS_TOKEN }}
|
||||||
|
GITEA_SERVER: git.cpatino.com
|
||||||
|
GITEA_REPO: c4patino/yumevim
|
||||||
|
run: |
|
||||||
|
git add -A
|
||||||
|
git commit -S -m "style: autoformatting all files with treefmt"
|
||||||
|
git push "https://forgejo:${TOKEN}@${GITEA_SERVER}/${GITEA_REPO}.git" HEAD:main
|
||||||
19
.github/workflows/format.yml
vendored
19
.github/workflows/format.yml
vendored
|
|
@ -1,19 +0,0 @@
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: ["main"]
|
|
||||||
tags: ["v*.*.*"]
|
|
||||||
pull_request:
|
|
||||||
types: [opened, reopened, synchronize]
|
|
||||||
branches: ["*"]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
format:
|
|
||||||
uses: c4patino/actions/.github/workflows/format.yml@main
|
|
||||||
with:
|
|
||||||
language: lua
|
|
||||||
96
flake.lock
generated
Normal file
96
flake.lock
generated
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1762233356,
|
||||||
|
"narHash": "sha256-cGS3lLTYusbEP/IJIWGgnkzIl+FA5xDvtiHyjalGr4k=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "ca534a76c4afb2bdc07b681dbc11b453bab21af8",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixos-25.05",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1761236834,
|
||||||
|
"narHash": "sha256-+pthv6hrL5VLW2UqPdISGuLiUZ6SnAXdd2DdUE+fV2Q=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "d5faa84122bc0a1fd5d378492efce4e289f8eac1",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"treefmt-nix": "treefmt-nix"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"treefmt-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1762352490,
|
||||||
|
"narHash": "sha256-hOP4GxAmeXI43U1lIrKbWI2k35M1/T/i8iJrO9m/GzY=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"rev": "4ef3dfdbb5ddfb9e39999a2f2b0c2637277859d4",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
30
flake.nix
Normal file
30
flake.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-25.05";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||||
|
};
|
||||||
|
outputs = {
|
||||||
|
flake-utils,
|
||||||
|
nixpkgs,
|
||||||
|
treefmt-nix,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
flake-utils.lib.eachDefaultSystem (
|
||||||
|
system: let
|
||||||
|
pkgs = import nixpkgs {inherit system;};
|
||||||
|
|
||||||
|
treefmtConfig = {...}: {
|
||||||
|
projectRootFile = "flake.nix";
|
||||||
|
programs = {
|
||||||
|
alejandra.enable = true;
|
||||||
|
stylua.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
treefmtEval = treefmt-nix.lib.evalModule pkgs (treefmtConfig {inherit pkgs;});
|
||||||
|
in {
|
||||||
|
formatter = treefmtEval.config.build.wrapper;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue