From bc1549dc3a901a02fe1928df13129a3d4f14514b Mon Sep 17 00:00:00 2001 From: Djalim Simaila Date: Sun, 26 Apr 2026 14:18:55 +0200 Subject: [PATCH] style: fix deno fmt and lint --- .github/workflows/deploy.yml | 27 +++++++++++++++++++++++++++ .github/workflows/lint.yml | 29 +++++++++++++++++++++++++++++ tests/e2e/promotions_test.ts | 5 ++++- tests/unit/promotions_test.ts | 11 +++++++++-- 4 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..7e44244 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,27 @@ +name: "Build and push image" + +on: + push: + branches: + - main + +jobs: + deploy: + name: "Build Docker image" + runs-on: ubuntu-latest + steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: registry.docker.polytech.djalim.fr + username: ${{ secrets.registry_login }} + password: ${{ secrets.registry_pass }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + tags: registry.docker.polytech.djalim.fr/polympr:latest diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..5194ae0 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,29 @@ +name: "Check Deno code" + +on: + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + check-code: + name: "Check Deno code" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + + - name: Check formatting + run: deno fmt --check + + - name: Check linting + run: deno lint + + - name: Run tests + run: deno test -A --no-check tests/ diff --git a/tests/e2e/promotions_test.ts b/tests/e2e/promotions_test.ts index 9be35fb..5a3e6ff 100644 --- a/tests/e2e/promotions_test.ts +++ b/tests/e2e/promotions_test.ts @@ -57,7 +57,10 @@ Deno.test({ async fn() { await truncateAll(); const res = await promotionsHandler.POST!( - makeJsonRequest("/promotions", "POST", { idPromo: "INFO3-2025", annee: "2025" }), + makeJsonRequest("/promotions", "POST", { + idPromo: "INFO3-2025", + annee: "2025", + }), makeEmployeeContext(), ); assertEquals(res.status, 201); diff --git a/tests/unit/promotions_test.ts b/tests/unit/promotions_test.ts index 6883045..b725bc5 100644 --- a/tests/unit/promotions_test.ts +++ b/tests/unit/promotions_test.ts @@ -41,7 +41,12 @@ Deno.test("mock API: GET /promotions/:id returns one", async () => { }); Deno.test("mock API: GET /promotions/:id 404 when not found", async () => { - mockFetch({ "/promotions/UNKNOWN": { status: 404, body: { error: "Ressource introuvable" } } }); + mockFetch({ + "/promotions/UNKNOWN": { + status: 404, + body: { error: "Ressource introuvable" }, + }, + }); try { const res = await fetch("http://localhost/api/promotions/UNKNOWN"); assertEquals(res.status, 404); @@ -83,7 +88,9 @@ Deno.test("mock API: POST /promotions 400 on missing fields", async () => { Deno.test("mock API: PUT /promotions/:id updates promotion", async () => { const updated = { idPromo: "4AFISE25/26", annee: "2026" }; - mockFetch({ "/promotions/4AFISE25%2F26": { method: "PUT", status: 200, body: updated } }); + mockFetch({ + "/promotions/4AFISE25%2F26": { method: "PUT", status: 200, body: updated }, + }); try { const res = await fetch("http://localhost/api/promotions/4AFISE25%2F26", { method: "PUT",