refactor: implement comprehensive DRY patterns for actions #82
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: write | |
| env: | |
| GO_VERSION: "1.24.x" | |
| jobs: | |
| test: | |
| name: Test and Quality Checks | |
| runs-on: ${{ matrix.os }} | |
| if: github.event_name == 'pull_request' || github.event_name == 'push' | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| go-version: ["1.24.x"] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go-${{ matrix.go-version }}- | |
| ${{ runner.os }}-go- | |
| - name: Install development tools | |
| run: make install-tools | |
| - name: Download dependencies | |
| run: make deps | |
| - name: Verify dependencies | |
| run: go mod verify | |
| - name: Format check | |
| run: make fmt-check | |
| - name: Vet code | |
| run: make vet | |
| - name: Run golangci-lint | |
| run: make lint | |
| - name: Run tests | |
| run: make test-ci | |
| - name: Run tests with coverage | |
| run: make test-coverage | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| if: matrix.os == 'ubuntu-latest' | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload test results to Codecov | |
| if: ${{ !cancelled() }} | |
| uses: codecov/test-results-action@v1 | |
| with: | |
| fail_ci_if_error: true | |
| files: ./junit-unit.xml | |
| name: task-engine-tests | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| release-validation: | |
| name: Release Validation | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Install development tools | |
| run: make install-tools | |
| - name: Run tests before release | |
| run: make test-ci | |
| - name: Run linting before release | |
| run: make lint | |
| - name: Validate library builds | |
| run: | | |
| # Validate that the library can be built successfully | |
| go build ./... | |
| - name: Create release documentation | |
| run: | | |
| VERSION=${{ github.event.release.tag_name }} | |
| COMMIT_SHA=${{ github.sha }} | |
| BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
| echo "# Task Engine Release ${VERSION}" > release-info.md | |
| echo "" >> release-info.md | |
| echo "- **Version**: ${VERSION}" >> release-info.md | |
| echo "- **Commit**: ${COMMIT_SHA}" >> release-info.md | |
| echo "- **Build Date**: ${BUILD_DATE}" >> release-info.md | |
| echo "- **Go Version**: ${{ env.GO_VERSION }}" >> release-info.md | |
| echo "" >> release-info.md | |
| echo "## Installation" >> release-info.md | |
| echo "" >> release-info.md | |
| echo '```bash' >> release-info.md | |
| echo "go get github.com/ndizazzo/task-engine@${VERSION}" >> release-info.md | |
| echo '```' >> release-info.md | |
| echo "" >> release-info.md | |
| echo "## Compatibility" >> release-info.md | |
| echo "" >> release-info.md | |
| echo "This release has been tested on:" >> release-info.md | |
| echo "- **Operating Systems**: Linux, macOS" >> release-info.md | |
| echo "- **Go Versions**: ${{ env.GO_VERSION }}+" >> release-info.md | |
| - name: Upload release documentation | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: release-info.md | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: false | |
| security-scan: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' || github.event_name == 'push' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| - name: Install development tools | |
| run: make install-tools | |
| - name: Run security and vulnerability scans | |
| run: make security |