From defd6072e1602e8045d6e32d43fa1837e172054c Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sat, 19 Oct 2024 06:57:36 -0400 Subject: [PATCH] chore(pre-commit): use google/yamlfmt --- .gitea/workflows/build.yaml | 114 ++++++++++++++++---------------- .gitea/workflows/submodule.yaml | 90 ++++++++++++------------- .golangci.yaml | 21 +++--- .pre-commit-config.yaml | 71 ++++++++++---------- 4 files changed, 145 insertions(+), 151 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index db24d8b..1d99eba 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -1,61 +1,59 @@ ---- name: build on: - - push - - pull_request - + - push + - pull_request jobs: - build: - container: - image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:golang-ubuntu-latest - volumes: - - /home/actions/.ssh:/root/.ssh - steps: - - name: Check out repository code - uses: https://gitea.com/BoYanZh/checkout@focs - - name: Display Go version - run: go version - - name: Prepare - run: | - go env -w GO111MODULE=on - go env -w GOPROXY=https://goproxy.io,direct - chown -R root:root /root/.ssh - # - name: Setup Joint-Teapot - # run: | - # pip install git+https://ghp.ci/https://github.com/BoYanZh/Joint-Teapot - - name: Lint - run: make lint - - name: Build - run: make build - - name: Version - run: ./build/joj3 -version - - name: Test - run: | - make prepare-test - make ci-test - trigger-build-image: - container: - image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:ubuntu-latest - volumes: - - /home/actions/.ssh:/root/.ssh - needs: build - if: github.ref == 'refs/heads/master' - steps: - - name: Set up Git - run: | - git config --global user.name "gitea-actions[bot]" - git config --global user.email "gitea-actions[bot]@users.noreply.gitea.com" - chown -R root:root /root/.ssh - - name: Clone, Commit and Push - shell: bash - run: | - git clone ssh://git@focs.ji.sjtu.edu.cn:2222/JOJ/runner-images.git runner-images - cd runner-images - git submodule update --init --remote --force - git add -A - if echo "${{ github.event.head_commit.message }}" | grep -q "force build"; then - git commit --allow-empty -m "chore: trigger force build gitea actions by JOJ3" - else - git commit --allow-empty -m "chore: trigger gitea actions by JOJ3" - fi - git push + build: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:golang-ubuntu-latest + volumes: + - /home/actions/.ssh:/root/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + - name: Display Go version + run: go version + - name: Prepare + run: | + go env -w GO111MODULE=on + go env -w GOPROXY=https://goproxy.io,direct + chown -R root:root /root/.ssh + # - name: Setup Joint-Teapot + # run: | + # pip install git+https://ghp.ci/https://github.com/BoYanZh/Joint-Teapot + - name: Lint + run: make lint + - name: Build + run: make build + - name: Version + run: ./build/joj3 -version + - name: Test + run: | + make prepare-test + make ci-test + trigger-build-image: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:ubuntu-latest + volumes: + - /home/actions/.ssh:/root/.ssh + needs: build + if: github.ref == 'refs/heads/master' + steps: + - name: Set up Git + run: | + git config --global user.name "gitea-actions[bot]" + git config --global user.email "gitea-actions[bot]@users.noreply.gitea.com" + chown -R root:root /root/.ssh + - name: Clone, Commit and Push + shell: bash + run: | + git clone ssh://git@focs.ji.sjtu.edu.cn:2222/JOJ/runner-images.git runner-images + cd runner-images + git submodule update --init --remote --force + git add -A + if echo "${{ github.event.head_commit.message }}" | grep -q "force build"; then + git commit --allow-empty -m "chore: trigger force build gitea actions by JOJ3" + else + git commit --allow-empty -m "chore: trigger gitea actions by JOJ3" + fi + git push diff --git a/.gitea/workflows/submodule.yaml b/.gitea/workflows/submodule.yaml index c5ee259..4b2ed9b 100644 --- a/.gitea/workflows/submodule.yaml +++ b/.gitea/workflows/submodule.yaml @@ -1,49 +1,47 @@ ---- name: submodules sync on: - push: - branches: - - master - + push: + branches: + - master jobs: - sync: - container: - image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:ubuntu-latest - volumes: - - /home/actions/.ssh:/root/.ssh - steps: - - name: Check out repository code - uses: https://gitea.com/BoYanZh/checkout@focs - with: - fetch-depth: 0 - - name: Set up Git - run: | - git config --global user.name "gitea-actions[bot]" - git config --global user.email "gitea-actions[bot]@users.noreply.gitea.com" - chown -R root:root /root/.ssh - git remote set-url origin ssh://git@focs.ji.sjtu.edu.cn:2222/JOJ/JOJ3.git - - name: Check Git status - run: | - echo git remote -v - git remote -v - echo ssh -T git@focs.ji.sjtu.edu.cn -p 2222 - ssh -T git@focs.ji.sjtu.edu.cn -p 2222 - echo git status - git status - - name: Git Submodule Update - run: | - git submodule init - git submodule update --init --recursive - git pull --recurse-submodules - git submodule update --remote --recursive - - name: Commit update - shell: bash - run: | - git fetch --all - git checkout master - git reset --hard origin/master - git status - git add . - git status - git diff-index --quiet HEAD || git commit -m "chore: update submodule references" - git push + sync: + container: + image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:ubuntu-latest + volumes: + - /home/actions/.ssh:/root/.ssh + steps: + - name: Check out repository code + uses: https://gitea.com/BoYanZh/checkout@focs + with: + fetch-depth: 0 + - name: Set up Git + run: | + git config --global user.name "gitea-actions[bot]" + git config --global user.email "gitea-actions[bot]@users.noreply.gitea.com" + chown -R root:root /root/.ssh + git remote set-url origin ssh://git@focs.ji.sjtu.edu.cn:2222/JOJ/JOJ3.git + - name: Check Git status + run: | + echo git remote -v + git remote -v + echo ssh -T git@focs.ji.sjtu.edu.cn -p 2222 + ssh -T git@focs.ji.sjtu.edu.cn -p 2222 + echo git status + git status + - name: Git Submodule Update + run: | + git submodule init + git submodule update --init --recursive + git pull --recurse-submodules + git submodule update --remote --recursive + - name: Commit update + shell: bash + run: | + git fetch --all + git checkout master + git reset --hard origin/master + git status + git add . + git status + git diff-index --quiet HEAD || git commit -m "chore: update submodule references" + git push diff --git a/.golangci.yaml b/.golangci.yaml index 9edd451..1f67b1b 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,13 +1,12 @@ ---- linters: - enable: - - gosec - - gocritic - - gofumpt - - gofmt - - goimports + enable: + - gosec + - gocritic + - gofumpt + - gofmt + - goimports issues: - exclude-rules: - - linters: - - gosec - text: G601 # false positive since go 1.22 + exclude-rules: + - linters: + - gosec + text: G601 # false positive since go 1.22 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8ec4c34..cfbe76c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,37 +1,36 @@ ---- repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 - hooks: - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace - - repo: https://github.com/mrtazz/checkmake.git - rev: 0.2.2 - hooks: - - id: checkmake - - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt - rev: 0.2.3 - hooks: - - id: yamlfmt - - repo: https://github.com/dnephin/pre-commit-golang - rev: v0.5.1 - hooks: - - id: golangci-lint - - id: go-mod-tidy - # - repo: local - # hooks: - # - id: make-build - # name: make build - # entry: make build - # language: system - # always_run: true - # stages: [pre-commit] - # pass_filenames: false - # - id: make-test - # name: make test - # entry: make test - # language: system - # always_run: true - # stages: [pre-commit] - # pass_filenames: false + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/mrtazz/checkmake.git + rev: 0.2.2 + hooks: + - id: checkmake + - repo: https://github.com/google/yamlfmt + rev: v0.13.0 + hooks: + - id: yamlfmt + - repo: https://github.com/dnephin/pre-commit-golang + rev: v0.5.1 + hooks: + - id: golangci-lint + - id: go-mod-tidy +# - repo: local +# hooks: +# - id: make-build +# name: make build +# entry: make build +# language: system +# always_run: true +# stages: [pre-commit] +# pass_filenames: false +# - id: make-test +# name: make test +# entry: make test +# language: system +# always_run: true +# stages: [pre-commit] +# pass_filenames: false