From 81341be6f68b0cdc606d9fab25a3a5de32a6cdb3 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sun, 4 May 2025 17:00:25 +0300 Subject: [PATCH] fixup workflows Signed-off-by: Vasiliy Tolstov --- .../ISSUE_TEMPLATE/bug_report.md | 0 .../feature-request---enhancement.md | 0 .../ISSUE_TEMPLATE/question.md | 0 {.gitea => .github}/PULL_REQUEST_TEMPLATE.md | 0 {.gitea => .github}/autoapprove.yml | 0 .github/workflows/job_coverage.yml | 53 +++++++++++++++++++ {.gitea => .github}/workflows/job_lint.yml | 12 ++--- .github/workflows/job_sync.yml | 52 ++++++++++++++++++ {.gitea => .github}/workflows/job_test.yml | 15 +++--- .github/workflows/job_tests.yml | 50 +++++++++++++++++ 10 files changed, 167 insertions(+), 15 deletions(-) rename {.gitea => .github}/ISSUE_TEMPLATE/bug_report.md (100%) rename {.gitea => .github}/ISSUE_TEMPLATE/feature-request---enhancement.md (100%) rename {.gitea => .github}/ISSUE_TEMPLATE/question.md (100%) rename {.gitea => .github}/PULL_REQUEST_TEMPLATE.md (100%) rename {.gitea => .github}/autoapprove.yml (100%) create mode 100644 .github/workflows/job_coverage.yml rename {.gitea => .github}/workflows/job_lint.yml (72%) create mode 100644 .github/workflows/job_sync.yml rename {.gitea => .github}/workflows/job_test.yml (74%) create mode 100644 .github/workflows/job_tests.yml diff --git a/.gitea/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md similarity index 100% rename from .gitea/ISSUE_TEMPLATE/bug_report.md rename to .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.gitea/ISSUE_TEMPLATE/feature-request---enhancement.md b/.github/ISSUE_TEMPLATE/feature-request---enhancement.md similarity index 100% rename from .gitea/ISSUE_TEMPLATE/feature-request---enhancement.md rename to .github/ISSUE_TEMPLATE/feature-request---enhancement.md diff --git a/.gitea/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md similarity index 100% rename from .gitea/ISSUE_TEMPLATE/question.md rename to .github/ISSUE_TEMPLATE/question.md diff --git a/.gitea/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from .gitea/PULL_REQUEST_TEMPLATE.md rename to .github/PULL_REQUEST_TEMPLATE.md diff --git a/.gitea/autoapprove.yml b/.github/autoapprove.yml similarity index 100% rename from .gitea/autoapprove.yml rename to .github/autoapprove.yml diff --git a/.github/workflows/job_coverage.yml b/.github/workflows/job_coverage.yml new file mode 100644 index 0000000..3238e77 --- /dev/null +++ b/.github/workflows/job_coverage.yml @@ -0,0 +1,53 @@ +name: coverage + +on: + push: + branches: [ main, v3, v4 ] + paths-ignore: + - '.github/**' + - '.gitea/**' + pull_request: + branches: [ main, v3, v4 ] + +jobs: + + build: + if: github.server_url != 'https://github.com' + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v4 + with: + filter: 'blob:none' + + - name: setup go + uses: actions/setup-go@v5 + with: + cache-dependency-path: "**/*.sum" + go-version: 'stable' + + - name: test coverage + run: | + go test -v -cover ./... -covermode=count -coverprofile coverage.out -coverpkg ./... + go tool cover -func coverage.out -o coverage.out + + - name: coverage badge + uses: tj-actions/coverage-badge-go@v2 + with: + green: 80 + filename: coverage.out + + - uses: stefanzweifel/git-auto-commit-action@v4 + name: autocommit + with: + commit_message: Apply Code Coverage Badge + skip_fetch: false + skip_checkout: false + file_pattern: ./README.md + + - name: push + if: steps.auto-commit-action.outputs.changes_detected == 'true' + uses: ad-m/github-push-action@master + with: + github_token: ${{ github.token }} + branch: ${{ github.ref }} diff --git a/.gitea/workflows/job_lint.yml b/.github/workflows/job_lint.yml similarity index 72% rename from .gitea/workflows/job_lint.yml rename to .github/workflows/job_lint.yml index d97e747..1c104db 100644 --- a/.gitea/workflows/job_lint.yml +++ b/.github/workflows/job_lint.yml @@ -3,10 +3,10 @@ name: lint on: pull_request: types: [opened, reopened, synchronize] - branches: - - master - - v3 - - v4 + branches: [ master, v3, v4 ] + paths-ignore: + - '.github/**' + - '.gitea/**' jobs: lint: @@ -20,10 +20,10 @@ jobs: uses: actions/setup-go@v5 with: cache-dependency-path: "**/*.sum" - go-version: 'stable' + go-version: 'stable' - name: setup deps run: go get -v ./... - name: run lint - uses: https://github.com/golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v6 with: version: 'latest' diff --git a/.github/workflows/job_sync.yml b/.github/workflows/job_sync.yml new file mode 100644 index 0000000..d0f7aa1 --- /dev/null +++ b/.github/workflows/job_sync.yml @@ -0,0 +1,52 @@ +name: sync + +on: + schedule: + - cron: '*/5 * * * *' + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + sync: + if: github.server_url != 'https://github.com' + runs-on: ubuntu-latest + steps: + - name: init + run: | + git config --global user.email "vtolstov " + git config --global user.name "github-actions[bot]" + echo "machine git.unistack.org login vtolstov password ${{ secrets.TOKEN_GITEA }}" >> /root/.netrc + echo "machine github.com login vtolstov password ${{ secrets.TOKEN_GITHUB }}" >> /root/.netrc + + - name: sync master + run: | + git clone --filter=blob:none --filter=tree:0 --branch master --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo + cd repo + git remote add --no-tags --fetch --track master upstream https://github.com/${GITHUB_REPOSITORY} + git pull --rebase upstream master + git push upstream master --progress + git push origin master --progress + cd ../ + rm -rf repo + + - name: sync v3 + run: | + git clone --filter=blob:none --filter=tree:0 --branch v3 --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo + cd repo + git remote add --no-tags --fetch --track v3 upstream https://github.com/${GITHUB_REPOSITORY} + git pull --rebase upstream v3 + git push upstream v3 --progress + git push origin v3 --progress + cd ../ + rm -rf repo + + - name: sync v4 + run: | + git clone --filter=blob:none --filter=tree:0 --branch v4 --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo + cd repo + git remote add --no-tags --fetch --track v4 upstream https://github.com/${GITHUB_REPOSITORY} + git pull --rebase upstream v4 + git push upstream v4 --progress + git push origin v4 --progress + cd ../ + rm -rf repo diff --git a/.gitea/workflows/job_test.yml b/.github/workflows/job_test.yml similarity index 74% rename from .gitea/workflows/job_test.yml rename to .github/workflows/job_test.yml index 08ae367..59a95ae 100644 --- a/.gitea/workflows/job_test.yml +++ b/.github/workflows/job_test.yml @@ -3,15 +3,12 @@ name: test on: pull_request: types: [opened, reopened, synchronize] - branches: - - master - - v3 - - v4 + branches: [ master, v3, v4 ] push: - branches: - - master - - v3 - - v4 + branches: [ master, v3, v4 ] + paths-ignore: + - '.github/**' + - '.gitea/**' jobs: test: @@ -31,4 +28,4 @@ jobs: - name: run test env: INTEGRATION_TESTS: yes - run: go generate ./... + run: go test -mod readonly -v ./... diff --git a/.github/workflows/job_tests.yml b/.github/workflows/job_tests.yml new file mode 100644 index 0000000..9af2291 --- /dev/null +++ b/.github/workflows/job_tests.yml @@ -0,0 +1,50 @@ +name: test + +on: + pull_request: + types: [opened, reopened, synchronize] + branches: [ master, v3, v4 ] + push: + branches: [ master, v3, v4 ] + paths-ignore: + - '.github/**' + - '.gitea/**' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v4 + with: + filter: 'blob:none' + - name: checkout tests + uses: actions/checkout@v4 + with: + ref: master + filter: 'blob:none' + repository: unistack-org/micro-tests + path: micro-tests + - name: setup go + uses: actions/setup-go@v5 + with: + cache-dependency-path: "**/*.sum" + go-version: 'stable' + - name: setup go work + env: + GOWORK: ${{ github.workspace }}/go.work + run: | + go work init + go work use . + go work use micro-tests + - name: setup deps + env: + GOWORK: ${{ github.workspace }}/go.work + run: go get -v ./... + - name: run tests + env: + INTEGRATION_TESTS: yes + GOWORK: ${{ github.workspace }}/go.work + run: | + cd micro-tests + go test -mod readonly -v ./... || true