3 Commits

Author SHA1 Message Date
sparshg
26e3d3db20 bump v1.1.0 2024-09-26 01:53:39 +05:30
sparshg
e49e5e086b working pipeline 2024-09-26 01:47:13 +05:30
sparshg
3e5fdf4615 add cd 2024-09-26 01:39:06 +05:30
8 changed files with 45 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
name: Deploy name: Deploy backend
on: on:
push: push:
@@ -7,9 +7,12 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
docker: docker-azure:
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: battleship environment: battleship
permissions:
id-token: write
contents: read
steps: steps:
- -
name: Login to Docker Hub name: Login to Docker Hub
@@ -28,6 +31,7 @@ jobs:
tags: ${{ secrets.DOCKER_IMAGE_PATH }}:${{ github.sha }} tags: ${{ secrets.DOCKER_IMAGE_PATH }}:${{ github.sha }}
cache-from: type=registry,ref=${{ secrets.DOCKER_IMAGE_PATH }}:buildcache cache-from: type=registry,ref=${{ secrets.DOCKER_IMAGE_PATH }}:buildcache
cache-to: type=registry,ref=${{ secrets.DOCKER_IMAGE_PATH }}:buildcache,mode=max cache-to: type=registry,ref=${{ secrets.DOCKER_IMAGE_PATH }}:buildcache,mode=max
- -
name: Azure login name: Azure login
uses: azure/login@v2 uses: azure/login@v2
@@ -39,8 +43,8 @@ jobs:
name: Deploy Container name: Deploy Container
uses: azure/container-apps-deploy-action@v1 uses: azure/container-apps-deploy-action@v1
with: with:
acrName: dockerhub registryUrl: docker.io
containerAppName: battleship containerAppName: battleship
resourceGroup: Battleship resourceGroup: Battleship
imageToDeploy: ${{ secrets.DOCKER_IMAGE_PATH }}:${{ github.sha }} imageToDeploy: docker.io/${{ secrets.DOCKER_IMAGE_PATH }}:${{ github.sha }}

View File

@@ -1,11 +1,13 @@
name: Deploy name: Deploy frontend
on: on:
push: push:
branches: [ "main" ] tags:
- v**
workflow_dispatch:
jobs: jobs:
build_site: build_frontend:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@@ -34,8 +36,8 @@ jobs:
# this should match the `pages` option in your adapter-static options # this should match the `pages` option in your adapter-static options
path: 'app/build/' path: 'app/build/'
deploy-site: deploy-frontend:
needs: build_site needs: build_frontend
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:

View File

@@ -11,14 +11,30 @@ env:
SQLX_OFFLINE: true SQLX_OFFLINE: true
jobs: jobs:
build: backend:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Check - name: cargo-check
run: cargo check run: cargo check
- name: Clippy - name: cargo-clippy
run: cargo clippy run: cargo clippy
- name: Format - name: cargo-fmt
run: cargo fmt --all --check 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

2
Cargo.lock generated
View File

@@ -154,7 +154,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
[[package]] [[package]]
name = "battleship" name = "battleship"
version = "0.1.0" version = "1.1.0"
dependencies = [ dependencies = [
"axum", "axum",
"dotenv", "dotenv",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "battleship" name = "battleship"
version = "0.1.0" version = "1.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@@ -8,7 +8,7 @@
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .", "lint": "eslint .",
"format": "prettier --write ." "format": "prettier --write ."
}, },
"devDependencies": { "devDependencies": {
@@ -38,4 +38,4 @@
"lucide-svelte": "^0.441.0", "lucide-svelte": "^0.441.0",
"socket.io-client": "^4.7.5" "socket.io-client": "^4.7.5"
} }
} }

View File

@@ -38,7 +38,7 @@ export class State {
}); });
this.socket.on('attacked', ({ by, at, hit, sunk }) => { this.socket.on('attacked', ({ by, at, hit, sunk }) => {
const [i, j]: [number, number] = at; 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) { if (by == this.socket.id) {
this.turn = (hit) ? 1 : -1; this.turn = (hit) ? 1 : -1;
} else { } else {
@@ -46,7 +46,7 @@ export class State {
} }
if (hit) { if (hit) {
board.board[i][j] = 'h'; 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]; const [tx, ty] = [i + x, j + y];
if (tx < 0 || tx >= 10 || ty < 0 || ty >= 10) continue; if (tx < 0 || tx >= 10 || ty < 0 || ty >= 10) continue;
if (board.board[tx][ty] == 'e') if (board.board[tx][ty] == 'e')
@@ -132,7 +132,7 @@ export class Board {
isOverlapping(x: number, y: number, length: number, dir: number): boolean { isOverlapping(x: number, y: number, length: number, dir: number): boolean {
for (let i = -1; i < 2; i++) { for (let i = -1; i < 2; i++) {
for (let j = -1; j < length + 1; j++) { 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 (tx < 0 || tx >= 10 || ty < 0 || ty >= 10) continue;
if (this.board[tx][ty] != 'e') return true; if (this.board[tx][ty] != 'e') return true;
} }

View File

@@ -5,7 +5,7 @@ export default {
extend: {}, extend: {},
}, },
plugins: [ plugins: [
require('daisyui'), require('daisyui'), // eslint-disable-line
], ],
daisyui: { daisyui: {