diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..04ffcc1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,63 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + lint: + runs-on: ubuntu-latest + container: + image: golang:1.18 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.60 + + test: + runs-on: ubuntu-latest + container: + image: golang:1.18 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run tests + run: | + set -eux + go test -v -coverprofile=coverage.txt -covermode=atomic ./... + + - name: Upload coverage + uses: actions/upload-artifact@v4 + with: + name: coverage + path: coverage.txt + + publish: + needs: test + runs-on: ubuntu-latest + container: + image: golang:1.18 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download coverage + uses: actions/download-artifact@v4 + with: + name: coverage + path: . + + - name: Publish coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 5a8f92a..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: main -on: - push: - branches: - - main - pull_request: - branches: - - main -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: 1.18 - - - name: Checkout code - uses: actions/checkout@v4 - - - name: Run golangci-lint - uses: golangci/golangci-lint-action@v6 - with: - version: v1.60 - - - name: Run tests - run: | - go test -coverprofile=coverage.txt -covermode=atomic ./... - - - name: Publish coverage - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: ./coverage.txt