Merge pull request #20 from HTW-ALADIN/codex/noise-generation-wrapper… #13
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: noise-generation-service | |
| on: | |
| push: | |
| branches: ["master"] | |
| paths: | |
| - "services/noise-generation-service/**" | |
| pull_request: | |
| branches: ["master"] | |
| paths: | |
| - "services/noise-generation-service/**" | |
| defaults: | |
| run: | |
| working-directory: services/noise-generation-service | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - name: Cache dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: services/noise-generation-service | |
| - name: Formatting check | |
| run: cargo fmt --check | |
| - name: Clippy linting | |
| run: cargo clippy --all-targets --all-features -- -D warnings | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: services/noise-generation-service | |
| - name: Run tests | |
| run: | | |
| # Start server in background for integration tests | |
| cargo run -- server & | |
| SERVER_PID=$! | |
| # Wait for server to be ready | |
| for i in $(seq 1 30); do | |
| if curl -s http://localhost:8000/v1/algorithms > /dev/null 2>&1; then | |
| echo "Server is ready" | |
| break | |
| fi | |
| echo "Waiting for server... ($i/30)" | |
| sleep 1 | |
| done | |
| # Run all tests | |
| cargo test || EXIT_CODE=$? | |
| # Stop the server | |
| kill $SERVER_PID 2>/dev/null || true | |
| wait $SERVER_PID 2>/dev/null || true | |
| exit ${EXIT_CODE:-0} | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: services/noise-generation-service/coverage/lcov.info | |
| flags: noise-generation-service | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: false | |
| if: always() | |
| generate-openapi: | |
| name: Generate OpenAPI Spec | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: services/noise-generation-service | |
| - name: Generate OpenAPI spec | |
| run: cargo run -- openapi --output noise-generation-service.openapi.json | |
| - name: Upload OpenAPI spec | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: openapi-spec-noise-generation-service | |
| path: services/noise-generation-service/noise-generation-service.openapi.json | |
| build: | |
| name: Build & Push Docker Image | |
| runs-on: ubuntu-latest | |
| needs: generate-openapi | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ github.repository_owner }}/noise-generation-service | |
| tags: | | |
| type=sha,prefix=sha- | |
| type=raw,value=latest | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: services/noise-generation-service | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |