Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 73 additions & 1 deletion .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,54 @@ jobs:
working-directory: backend
run: cargo test -p st_core

- name: Check pairing module
working-directory: backend
run: cargo check -p pairing

- name: Test pairing module
working-directory: backend
run: cargo test -p pairing

- name: Check metrics module
working-directory: backend
run: cargo check -p metrics

- name: Test metrics module
working-directory: backend
run: cargo test -p metrics

- name: Check tournament module
working-directory: backend
run: cargo check -p tournament

- name: Test tournament module
working-directory: backend
run: cargo test -p tournament

- name: Check validation module
working-directory: backend
run: cargo check -p validation

- name: Test validation module
working-directory: backend
run: cargo test -p validation

- name: Check archiving module
working-directory: backend
run: cargo check -p archiving

- name: Test archiving module
working-directory: backend
run: cargo test -p archiving

- name: Check API integration
working-directory: backend
run: cargo check -p api

- name: Run integration tests
working-directory: backend
run: cargo test -p integration_tests

- name: Run backend tests
working-directory: backend
run: cargo test --workspace --exclude chess
Expand All @@ -88,10 +132,38 @@ jobs:
cargo install cargo-audit
cargo audit

monitoring-test:
name: Test Monitoring Stack
runs-on: ubuntu-latest
needs: test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Start monitoring stack
working-directory: backend
run: |
docker-compose -f docker-compose.monitoring.yml up -d
sleep 30

- name: Test Prometheus endpoint
run: |
curl -f http://localhost:9090/-/healthy || exit 1

- name: Test Grafana endpoint
run: |
curl -f http://localhost:3000/api/health || exit 1

- name: Cleanup
working-directory: backend
run: |
docker-compose -f docker-compose.monitoring.yml down
Comment on lines +144 to +161

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Is docker-compose v1 still preinstalled on GitHub Actions ubuntu-latest runners in 2026?

💡 Result:

No, docker-compose v1 is not preinstalled on GitHub Actions ubuntu-latest runners in 2026. ubuntu-latest refers to Ubuntu 24.04, and official documentation lists only "Docker Compose v2" (e.g., version 2.38.2 or later). Docker Compose v1 was deprecated and removed from Ubuntu images starting in 2024, with announcements confirming its removal across all Ubuntu runners. Users must use "docker compose" (v2) or install v1 manually if needed.

Citations:


🏁 Script executed:

#!/bin/bash
# Check if the workflow file exists
if [ -f ".github/workflows/backend.yml" ]; then
  echo "File exists. Reading lines 144-161:"
  sed -n '144,161p' .github/workflows/backend.yml
  echo ""
  echo "Full context around those lines (140-165):"
  sed -n '140,165p' .github/workflows/backend.yml
else
  echo "File does not exist at .github/workflows/backend.yml"
  # Try to find workflow files
  find .github/workflows -name "*.yml" -o -name "*.yaml" 2>/dev/null | head -20
fi

Repository: NOVUS-X/XLMate

Length of output: 1353


🏁 Script executed:

#!/bin/bash
# Search for all docker-compose usage in workflow files
echo "=== All docker-compose usages in workflows ==="
rg "docker-compose" .github/workflows/ --color never || echo "No matches found"

Repository: NOVUS-X/XLMate

Length of output: 292


Replace deprecated docker-compose v1 with docker compose v2.

Docker Compose v1 is not available on ubuntu-latest runners (Ubuntu 24.04+). The workflow will fail using the docker-compose binary; use docker compose instead. Additionally, replace sleep 30 with a polling loop on the health endpoints to reduce flakiness.

♻️ Proposed fix
       - name: Start monitoring stack
         working-directory: backend
         run: |
-          docker-compose -f docker-compose.monitoring.yml up -d
-          sleep 30
+          docker compose -f docker-compose.monitoring.yml up -d
+          for i in {1..30}; do
+            curl -fs http://localhost:9090/-/healthy && curl -fs http://localhost:3000/api/health && break
+            sleep 2
+          done
...
       - name: Cleanup
         working-directory: backend
         run: |
-          docker-compose -f docker-compose.monitoring.yml down
+          docker compose -f docker-compose.monitoring.yml down
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Start monitoring stack
working-directory: backend
run: |
docker-compose -f docker-compose.monitoring.yml up -d
sleep 30
- name: Test Prometheus endpoint
run: |
curl -f http://localhost:9090/-/healthy || exit 1
- name: Test Grafana endpoint
run: |
curl -f http://localhost:3000/api/health || exit 1
- name: Cleanup
working-directory: backend
run: |
docker-compose -f docker-compose.monitoring.yml down
- name: Start monitoring stack
working-directory: backend
run: |
docker compose -f docker-compose.monitoring.yml up -d
for i in {1..30}; do
curl -fs http://localhost:9090/-/healthy && curl -fs http://localhost:3000/api/health && break
sleep 2
done
- name: Test Prometheus endpoint
run: |
curl -f http://localhost:9090/-/healthy || exit 1
- name: Test Grafana endpoint
run: |
curl -f http://localhost:3000/api/health || exit 1
- name: Cleanup
working-directory: backend
run: |
docker compose -f docker-compose.monitoring.yml down
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/backend.yml around lines 144 - 161, Update the workflow
steps that start and tear down the monitoring stack to use the Docker Compose v2
CLI by replacing the `docker-compose -f docker-compose.monitoring.yml ...`
invocations in the "Start monitoring stack" and "Cleanup" steps with `docker
compose -f docker-compose.monitoring.yml ...`, and change the "Start monitoring
stack" step to remove `sleep 30` and instead implement a polling loop in the
"Test Prometheus endpoint" and "Test Grafana endpoint" steps that retries the
health checks (e.g., retry curl with a short delay and a timeout) until they
succeed or a max wait is reached to avoid flakiness; update the step names "Test
Prometheus endpoint" and "Test Grafana endpoint" to use those polling retries
for robustness.


docker-build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: test
needs: [test, monitoring-test]
if: github.event_name == 'push'

steps:
Expand Down
5 changes: 5 additions & 0 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ members = [
"modules/tournament",
"modules/matchmaking",
"modules/engine",
"modules/pairing",
"modules/st_core",
"modules/metrics",
"modules/validation",
"modules/archiving",
"modules/integration_tests",
]

[workspace.dependencies]
Expand Down
61 changes: 61 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Use Rust official image as base
FROM rust:1.75-slim as builder

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Docker BuildKit FromAsCasing warning lowercase as builder

💡 Result:

The "FromAsCasing" warning in Docker BuildKit occurs when the casing of 'FROM' and 'as' keywords in a Dockerfile do not match, such as FROM image as builder (uppercase FROM, lowercase 'as'). This is a build check rule for consistency and readability. To fix it, make the casing consistent: - Both uppercase: FROM debian:latest AS builder (recommended) - Or both lowercase: from debian:latest as builder This warning appears during builds with recent Docker versions using BuildKit (e.g., Docker 27+). It's non-blocking but improves Dockerfile quality. Use docker build --check . to validate. Example bad: FROM debian:latest as builder Warning: FromAsCasing: 'as' and 'FROM' keywords' casing do not match

Citations:


🌐 Web query:

Dockerfile FROM AS uppercase lowercase syntax requirements

💡 Result:

Dockerfile instructions like FROM and AS are not case-sensitive; they can be written in uppercase, lowercase, or mixed case and will parse correctly. However, the official convention is to use UPPERCASE for instructions to distinguish them from arguments (e.g., FROM image AS builder). Mixing cases within the same FROM ... AS instruction (e.g., FROM ... as builder) triggers a Docker build check warning (FromAsCasing) for readability, though it still builds successfully. All-lowercase or all-uppercase is acceptable and passes checks.

Citations:


🌐 Web query:

Docker Dockerfile best practices AS builder casing

💡 Result:

Dockerfile best practices recommend consistent casing for FROM and AS keywords in multi-stage builds, and using all lowercase for stage names like "builder". Key guidelines from official Docker documentation: 1. Match casing between FROM/from and AS/as: Use both uppercase (FROM ... AS builder) or both lowercase (from ... as builder) for readability. Mixing cases (e.g., FROM ... as builder) triggers the FromAsCasing build check warning. 2. Stage names should be all lowercase: Names like "BuilderBase" violate the StageNameCasing rule; use "builder-base" or "builder" instead. This distinguishes stage identifiers from uppercase Dockerfile instructions. Stage names are case-insensitive in references (e.g., COPY --from=builder works regardless), but consistency is enforced. Examples: Good (uppercase keywords, lowercase stage): FROM debian:latest AS builder ... COPY --from=builder /app /app Good (lowercase keywords, lowercase stage): from debian:latest as builder ... copy --from=builder /app /app Bad (mixed keyword casing): FROM debian:latest as builder # Triggers FromAsCasing Bad (uppercase stage name): FROM alpine AS BuilderBase # Triggers StageNameCasing These rules are part of Docker's build checks (hadolint-style) to improve readability and maintainability. Multi-stage builds with a "builder" stage are a core best practice for minimizing final image size by separating build dependencies from runtime.

Citations:


🏁 Script executed:

cat -n backend/Dockerfile | head -10

Repository: NOVUS-X/XLMate

Length of output: 339


Change as to AS to match FROM keyword casing.

Mixing cases in FROM ... AS (e.g., FROM ... as) triggers Docker BuildKit's FromAsCasing build check warning; use uppercase AS to match the FROM instruction for consistency.

Diff
-FROM rust:1.75-slim as builder
+FROM rust:1.75-slim AS builder
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
FROM rust:1.75-slim as builder
FROM rust:1.75-slim AS builder
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/Dockerfile` at line 2, The Dockerfile uses mixed casing in the FROM
instruction ("FROM rust:1.75-slim as builder"); change the token "as" to
uppercase "AS" so the line reads with matching casing for the FROM instruction
and its alias (i.e., use "AS builder") to satisfy the FromAsCasing check.


# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*

# Copy Cargo files
COPY Cargo.toml Cargo.lock ./

# Copy source code
COPY modules/ ./modules/
COPY src/ ./src/

# Build the application
RUN cargo build --release

# Runtime stage
FROM debian:bookworm-slim

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libpq5 \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*

# Create app user
RUN useradd -r -s /bin/false appuser

# Set working directory
WORKDIR /app

# Copy binary from builder
COPY --from=builder /app/target/release/api ./api

# Copy configuration files
COPY docker-compose.monitoring.yml ./
COPY monitoring/ ./monitoring/

# Change ownership
RUN chown -R appuser:appuser /app

# Switch to non-root user
USER appuser

# Expose port
EXPOSE 8080

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1

# Run the application
CMD ["./api"]
Loading
Loading