Repository navigation
Merge pull request #5 from alegeay/dev #4
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| env: | |
| CARGO_TERM_COLOR: always | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| release: | |
| name: Release | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set image name to lowercase | |
| run: echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >> $GITHUB_ENV | |
| env: | |
| IMAGE_NAME: ${{ github.repository }} | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy, rustfmt | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run Clippy | |
| run: cargo clippy --no-deps -- -Dwarnings | |
| - name: Run rustfmt | |
| run: cargo fmt --check | |
| - name: Build | |
| run: cargo build --release | |
| - name: Run tests | |
| run: cargo test | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v3 | |
| - name: Create GitVersion.yml | |
| run: | | |
| cat <<EOF > GitVersion.yml | |
| major-version-bump-message: '(breaking|major|incompatible):' | |
| minor-version-bump-message: '(feature|minor|enhancement|new|update|improvement|upgrade|feat):' | |
| patch-version-bump-message: '(fix|patch|bugfix|hotfix|correction|adjustment|tweak):' | |
| no-bump-message: '(none|skip|no-release|trivial|docs|documentation|style|refactor|chore|chore\(deps\)|test):' | |
| EOF | |
| - name: Run GitVersion | |
| id: gitversion | |
| uses: gittools/actions/gitversion/execute@v3 | |
| - name: Display GitVersion | |
| run: | | |
| echo "Version: ${{ env.majorMinorPatch }}" | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: | | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}:${{ env.majorMinorPatch }} | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Create tag | |
| uses: rickstaa/action-create-tag@v1 | |
| with: | |
| tag: v${{ env.majorMinorPatch }} | |
| force_push_tag: true | |
| - name: Create GitHub release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| generateReleaseNotes: true | |
| tag: v${{ env.majorMinorPatch }} | |
| # Integration tests | |
| - name: Pull image | |
| run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}:${{ env.majorMinorPatch }} | |
| - name: Run container | |
| run: | | |
| docker run -d --name naolametric-test \ | |
| -p 8080:8080 \ | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}:${{ env.majorMinorPatch }} | |
| sleep 3 | |
| - name: Test health endpoint | |
| run: | | |
| response=$(curl -s http://localhost:8080/health) | |
| if [ "$response" != "OK" ]; then | |
| echo "Health check failed: $response" | |
| exit 1 | |
| fi | |
| echo "Health check passed" | |
| - name: Test stops endpoint | |
| run: | | |
| response=$(curl -s "http://localhost:8080/stops?search=commerce&limit=1") | |
| if ! echo "$response" | grep -q "COMM"; then | |
| echo "Stops endpoint failed: $response" | |
| exit 1 | |
| fi | |
| echo "Stops endpoint passed" | |
| - name: Test main endpoint | |
| run: | | |
| response=$(curl -s "http://localhost:8080/?stop=COMM") | |
| if ! echo "$response" | grep -q "frames"; then | |
| echo "Main endpoint failed: $response" | |
| exit 1 | |
| fi | |
| echo "Main endpoint passed" | |
| - name: Show logs | |
| if: always() | |
| run: docker logs naolametric-test || true | |
| - name: Cleanup | |
| if: always() | |
| run: docker rm -f naolametric-test || true |