diff --git a/.github/workflows/cd-backend.yml b/.github/workflows/cd-backend.yml index e87dc33..d94a8e9 100644 --- a/.github/workflows/cd-backend.yml +++ b/.github/workflows/cd-backend.yml @@ -10,6 +10,9 @@ jobs: docker: runs-on: ubuntu-latest environment: battleship + permissions: + id-token: write + contents: read steps: - name: Login to Docker Hub @@ -28,13 +31,7 @@ jobs: tags: ${{ secrets.DOCKER_IMAGE_PATH }}:${{ github.sha }} cache-from: type=registry,ref=${{ secrets.DOCKER_IMAGE_PATH }}:buildcache cache-to: type=registry,ref=${{ secrets.DOCKER_IMAGE_PATH }}:buildcache,mode=max - azure: - runs-on: ubuntu-latest - environment: battleship - permissions: - id-token: write - contents: read - steps: + - name: Azure login uses: azure/login@v2 diff --git a/.github/workflows/cd-frontend.yml b/.github/workflows/cd-frontend.yml index 9bd7647..7ad0c13 100644 --- a/.github/workflows/cd-frontend.yml +++ b/.github/workflows/cd-frontend.yml @@ -2,8 +2,10 @@ name: Deploy on: push: - branches: [ "main" ] - + tags: + - v** + workflow_dispatch: + jobs: build_site: runs-on: ubuntu-latest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a81576b..7f14f63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,14 +11,30 @@ env: SQLX_OFFLINE: true jobs: - build: + backend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - - name: Check + - name: cargo-check run: cargo check - - name: Clippy + - name: cargo-Clippy run: cargo clippy - - name: Format - run: cargo fmt --all --check \ No newline at end of file + - name: cargo-fmt + run: cargo fmt --all --check + frontend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: 'app/package-lock.json' + - name: Install dependencies + working-directory: app + run: npm install + - name: lint + working-directory: app + run: npm run lint + \ No newline at end of file diff --git a/app/package.json b/app/package.json index f8beba7..6751607 100644 --- a/app/package.json +++ b/app/package.json @@ -8,7 +8,7 @@ "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "lint": "prettier --check . && eslint .", + "lint": "eslint .", "format": "prettier --write ." }, "devDependencies": { @@ -38,4 +38,4 @@ "lucide-svelte": "^0.441.0", "socket.io-client": "^4.7.5" } -} +} \ No newline at end of file diff --git a/app/src/lib/state.svelte.ts b/app/src/lib/state.svelte.ts index 0dfbdab..ce74893 100644 --- a/app/src/lib/state.svelte.ts +++ b/app/src/lib/state.svelte.ts @@ -38,7 +38,7 @@ export class State { }); this.socket.on('attacked', ({ by, at, hit, sunk }) => { const [i, j]: [number, number] = at; - let board = by == this.socket.id ? this.opponentBoard : this.playerBoard; + const board = by == this.socket.id ? this.opponentBoard : this.playerBoard; if (by == this.socket.id) { this.turn = (hit) ? 1 : -1; } else { @@ -46,7 +46,7 @@ export class State { } if (hit) { board.board[i][j] = 'h'; - for (let [x, y] of [[-1, -1], [1, 1], [1, -1], [-1, 1]]) { + for (const [x, y] of [[-1, -1], [1, 1], [1, -1], [-1, 1]]) { const [tx, ty] = [i + x, j + y]; if (tx < 0 || tx >= 10 || ty < 0 || ty >= 10) continue; if (board.board[tx][ty] == 'e') @@ -132,7 +132,7 @@ export class Board { isOverlapping(x: number, y: number, length: number, dir: number): boolean { for (let i = -1; i < 2; i++) { for (let j = -1; j < length + 1; j++) { - let [tx, ty] = [x + (dir ? i : j), y + (dir ? j : i)]; + const [tx, ty] = [x + (dir ? i : j), y + (dir ? j : i)]; if (tx < 0 || tx >= 10 || ty < 0 || ty >= 10) continue; if (this.board[tx][ty] != 'e') return true; } diff --git a/app/tailwind.config.js b/app/tailwind.config.js index a21f107..13c482b 100644 --- a/app/tailwind.config.js +++ b/app/tailwind.config.js @@ -5,7 +5,7 @@ export default { extend: {}, }, plugins: [ - require('daisyui'), + require('daisyui'), // eslint-disable-line ], daisyui: {