fix bug #11
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: Build and Test | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| - '.gitignore' | |
| pull_request: | |
| branches: [ main ] | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| - '.gitignore' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| lint-api: | |
| name: Lint API Server | |
| 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.24' | |
| cache-dependency-path: api-server/go.sum | |
| - name: Run go vet | |
| working-directory: api-server | |
| run: go vet ./... | |
| - name: Run go fmt check | |
| working-directory: api-server | |
| run: | | |
| if [ -n "$(gofmt -l .)" ]; then | |
| echo "Go code is not formatted:" | |
| gofmt -d . | |
| exit 1 | |
| fi | |
| test-api: | |
| name: Test API Server | |
| 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.24' | |
| cache-dependency-path: api-server/go.sum | |
| - name: Download dependencies | |
| working-directory: api-server | |
| run: go mod download | |
| - name: Run tests | |
| working-directory: api-server | |
| run: go test -v -race -coverprofile=coverage.out ./... | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: api-coverage | |
| path: api-server/coverage.out | |
| retention-days: 7 | |
| lint-web: | |
| name: Lint Web UI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| working-directory: web-ui | |
| run: | | |
| rm -rf node_modules package-lock.json | |
| npm install | |
| - name: Run ESLint | |
| working-directory: web-ui | |
| run: npm run lint | |
| test-web: | |
| name: Test Web UI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| working-directory: web-ui | |
| run: | | |
| rm -rf node_modules package-lock.json | |
| npm install | |
| - name: Run tests | |
| working-directory: web-ui | |
| run: npm test -- --run --coverage | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: web-coverage | |
| path: web-ui/coverage/ | |
| retention-days: 7 | |
| build-docker: | |
| name: Build Docker Images | |
| runs-on: ubuntu-latest | |
| needs: [lint-api, test-api, lint-web, test-web] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| component: [api-server, web-ui] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./${{ matrix.component }} | |
| file: ./${{ matrix.component }}/Dockerfile | |
| platforms: linux/amd64 | |
| push: false | |
| tags: bison/${{ matrix.component }}:test | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| lint-helm: | |
| name: Lint Helm Chart | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Helm | |
| uses: azure/setup-helm@v4 | |
| with: | |
| version: 'latest' | |
| - name: Lint Helm chart | |
| run: | | |
| helm lint deploy/charts/bison | |
| - name: Template Helm chart | |
| run: | | |
| helm template bison deploy/charts/bison \ | |
| --set apiServer.image.tag=test \ | |
| --set webUI.image.tag=test \ | |
| > /dev/null | |
| summary: | |
| name: Build Summary | |
| runs-on: ubuntu-latest | |
| needs: [lint-api, test-api, lint-web, test-web, build-docker, lint-helm] | |
| if: always() | |
| steps: | |
| - name: Check results | |
| run: | | |
| echo "Build and test summary:" | |
| echo "- API Lint: ${{ needs.lint-api.result }}" | |
| echo "- API Test: ${{ needs.test-api.result }}" | |
| echo "- Web Lint: ${{ needs.lint-web.result }}" | |
| echo "- Web Test: ${{ needs.test-web.result }}" | |
| echo "- Docker Build: ${{ needs.build-docker.result }}" | |
| echo "- Helm Lint: ${{ needs.lint-helm.result }}" | |
| if [ "${{ needs.lint-api.result }}" != "success" ] || \ | |
| [ "${{ needs.test-api.result }}" != "success" ] || \ | |
| [ "${{ needs.lint-web.result }}" != "success" ] || \ | |
| [ "${{ needs.test-web.result }}" != "success" ] || \ | |
| [ "${{ needs.build-docker.result }}" != "success" ] || \ | |
| [ "${{ needs.lint-helm.result }}" != "success" ]; then | |
| echo "❌ Some checks failed" | |
| exit 1 | |
| else | |
| echo "✅ All checks passed" | |
| fi |