Merge pull request #14 from armitageee/copilot/setup-bazel-build-work… #76
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 | |
| # This workflow runs only when core application files are changed | |
| # Triggers: internal/**, main.go, go.mod, go.sum, Dockerfile, .dockerignore, workflow files, Bazel files | |
| on: | |
| push: | |
| branches: [ main, develop, feat/bazelbuild ] | |
| paths: | |
| - 'internal/**' # Core application code | |
| - 'main.go' # Main application entry point | |
| - 'go.mod' # Go module dependencies | |
| - 'go.sum' # Go module checksums | |
| - 'Dockerfile' # Docker configuration | |
| - '.dockerignore' # Docker ignore file | |
| - '.github/workflows/**' # CI/CD workflow changes | |
| - 'BUILD.bazel' # Bazel build files | |
| - 'WORKSPACE' # Bazel workspace | |
| - 'MODULE.bazel' # Bazel module | |
| - '.bazelrc' # Bazel configuration | |
| - '.bazelversion' # Bazel version | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'internal/**' | |
| - 'main.go' | |
| - 'go.mod' | |
| - 'go.sum' | |
| - 'Dockerfile' | |
| - '.dockerignore' | |
| - '.github/workflows/**' | |
| - 'BUILD.bazel' | |
| - 'WORKSPACE' | |
| - 'MODULE.bazel' | |
| - '.bazelrc' | |
| - '.bazelversion' | |
| release: | |
| types: [ published ] | |
| env: | |
| BAZEL_VERSION: '7.0.0' | |
| jobs: | |
| unit-test: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Bazelisk | |
| uses: bazelbuild/setup-bazelisk@v3 | |
| - name: Mount bazel cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/bazel | |
| key: bazel-cache-${{ runner.os }}-${{ hashFiles('**/BUILD.bazel', '**/WORKSPACE', '**/MODULE.bazel') }} | |
| restore-keys: | | |
| bazel-cache-${{ runner.os }}- | |
| - name: Run unit tests | |
| run: | | |
| bazel test //... --test_tag_filters=-integration --test_output=errors --verbose_failures | |
| - name: Generate coverage report | |
| run: | | |
| bazel coverage //... --test_tag_filters=-integration --combined_report=lcov | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./bazel-out/_coverage/_coverage_report.dat | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| integration-test: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Bazelisk | |
| uses: bazelbuild/setup-bazelisk@v3 | |
| - name: Mount bazel cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/bazel | |
| key: bazel-cache-${{ runner.os }}-${{ hashFiles('**/BUILD.bazel', '**/WORKSPACE', '**/MODULE.bazel') }} | |
| restore-keys: | | |
| bazel-cache-${{ runner.os }}- | |
| - name: Run integration tests | |
| env: | |
| FACEIT_API_KEY: ${{ secrets.FACEIT_API_KEY }} | |
| run: | | |
| bazel test //internal/repository/... --test_tag_filters=integration --test_output=errors --verbose_failures | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' | |
| cache: true | |
| - name: Run golangci-lint | |
| uses: golangci/golangci-lint-action@v6 | |
| with: | |
| version: latest | |
| args: --timeout=5m | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Bazelisk | |
| uses: bazelbuild/setup-bazelisk@v3 | |
| - name: Mount bazel cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/bazel | |
| key: bazel-cache-${{ runner.os }}-${{ hashFiles('**/BUILD.bazel', '**/WORKSPACE', '**/MODULE.bazel') }} | |
| restore-keys: | | |
| bazel-cache-${{ runner.os }}- | |
| - name: Build application | |
| run: | | |
| bazel build //:faceit-cli --verbose_failures | |