diff --git a/.github/changelog.yml b/.github/changelog.yml new file mode 100644 index 0000000..6086515 --- /dev/null +++ b/.github/changelog.yml @@ -0,0 +1,36 @@ +title: '## Change Log' +# style allow: simple, markdown(mkdown), ghr(gh-release) +style: gh-release +# group names +names: [Refactor, Fixed, Feature, Update, Other] +repo_url: https://github.com/gookit/gcli + +filters: + # message length should >= 12 + - name: msg_len + min_len: 12 + # message words should >= 3 + - name: words_len + min_len: 3 + - name: keyword + keyword: format code + exclude: true + - name: keywords + keywords: format code, action test + exclude: true + +# group match rules +# not matched will use 'Other' group. +rules: + - name: Refactor + start_withs: [refactor, break] + contains: ['refactor:'] + - name: Fixed + start_withs: [fix] + contains: ['fix:'] + - name: Feature + start_withs: [feat, new] + contains: [feature] + - name: Update + start_withs: [update, 'up:'] + contains: [] diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d921d0f..0ddfbab 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,3 +5,9 @@ updates: schedule: interval: daily open-pull-requests-limit: 10 + +- package-ecosystem: "github-actions" + directory: "/" + schedule: + # Check for updates to GitHub Actions every weekday + interval: "daily" diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 96405e5..88a0dc7 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,37 +1,64 @@ name: Unit-Tests -on: [push] +on: + pull_request: + paths: + - 'go.mod' + - '**.go' + - '**.yml' + push: + paths: + - '**.go' + - 'go.mod' + - '**.yml' + jobs: test: - name: Test on go ${{ matrix.go_version }} and ${{ matrix.os }} - runs-on: ${{ matrix.os }} + name: Test on go ${{ matrix.go_version }} + runs-on: ubuntu-latest strategy: matrix: go_version: [1.15, 1.16, 1.17, 1.18] - os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - name: Check out code - uses: actions/checkout@v2 - # https://github.com/actions/setup-go - - name: Use Go ${{ matrix.go_version }} - timeout-minutes: 3 - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go_version }} - - - name: Run unit tests - # run: go test -v -cover ./... - # must add " for profile.cov on windows OS - run: go test -v -coverprofile="profile.cov" ./... - - - name: Send coverage - uses: shogo82148/actions-goveralls@v1 - if: ${{ matrix.os == 'ubuntu-latest' }} - with: - path-to-profile: profile.cov - flag-name: Go-${{ matrix.go_version }} - parallel: true + - name: Check out code + uses: actions/checkout@v3 + + - name: Setup Go Faster + uses: WillAbides/setup-go-faster@v1.7.0 + timeout-minutes: 3 + with: + go-version: ${{ matrix.go_version }} + + - name: Revive check + uses: morphy2k/revive-action@v2.3.1 + with: + # Exclude patterns, separated by semicolons (optional) + exclude: "./_examples/..." + + - name: Run static check + uses: reviewdog/action-staticcheck@v1 + if: ${{ github.event_name == 'pull_request'}} + with: + github_token: ${{ secrets.github_token }} + # Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review]. + reporter: github-pr-check + # Report all results. [added,diff_context,file,nofilter]. + filter_mode: added + # Exit with 1 when it find at least one finding. + fail_on_error: true + + - name: Run unit tests + # run: go test -v -cover ./... + # must add " for profile.cov on windows OS + run: go test -v -coverprofile="profile.cov" ./... + + - name: Send coverage + uses: shogo82148/actions-goveralls@v1 + with: + path-to-profile: profile.cov + flag-name: Go-${{ matrix.go_version }} + parallel: true # notifies that all test jobs are finished. # https://github.com/shogo82148/actions-goveralls @@ -41,4 +68,4 @@ jobs: steps: - uses: shogo82148/actions-goveralls@v1 with: - parallel-finished: true + parallel-finished: true \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f954e2..b0e6eee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,11 +13,19 @@ jobs: strategy: fail-fast: true matrix: - go: [1.17] + go_version: [1.17] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Go Faster + uses: WillAbides/setup-go-faster@v1.7.0 + timeout-minutes: 3 + with: + go-version: ${{ matrix.go_version }} - name: Setup ENV # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable @@ -25,14 +33,19 @@ jobs: echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV echo "RELEASE_NAME=$GITHUB_WORKFLOW" >> $GITHUB_ENV - - name: Display Env - run: env + - name: Generate changelog + run: | + go install github.com/gookit/gitw/cmd/chlog@latest + chlog -config .github/changelog.yml -output testdata/changelog.md prev last - # https://github.com/actions/create-release - - uses: meeDamian/github-release@2.0 + # https://github.com/softprops/action-gh-release + - name: Create release and upload assets + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - gzip: false - token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ env.RELEASE_TAG }} name: ${{ env.RELEASE_TAG }} -# files: kite-${{ env.RELEASE_TAG }}.phar + tag_name: ${{ env.RELEASE_TAG }} + body_path: testdata/changelog.md + token: ${{ secrets.GITHUB_TOKEN }} +# files: macos-chlog.exe