Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
26e3d3db20 | ||
|
e49e5e086b | ||
|
3e5fdf4615 |
30
.github/workflows/cd-backend.yml
vendored
30
.github/workflows/cd-backend.yml
vendored
@@ -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
|
||||||
@@ -25,6 +28,23 @@ jobs:
|
|||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.DOCKER_IMAGE_PATH }}:latest
|
tags: ${{ secrets.DOCKER_IMAGE_PATH }}:${{ github.sha }}
|
||||||
cache-from: type=gha
|
cache-from: type=registry,ref=${{ secrets.DOCKER_IMAGE_PATH }}:buildcache
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=registry,ref=${{ secrets.DOCKER_IMAGE_PATH }}:buildcache,mode=max
|
||||||
|
|
||||||
|
-
|
||||||
|
name: Azure login
|
||||||
|
uses: azure/login@v2
|
||||||
|
with:
|
||||||
|
client-id: ${{ secrets.AZURE_CLIENT_ID }}
|
||||||
|
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
||||||
|
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
||||||
|
-
|
||||||
|
name: Deploy Container
|
||||||
|
uses: azure/container-apps-deploy-action@v1
|
||||||
|
with:
|
||||||
|
registryUrl: docker.io
|
||||||
|
containerAppName: battleship
|
||||||
|
resourceGroup: Battleship
|
||||||
|
imageToDeploy: docker.io/${{ secrets.DOCKER_IMAGE_PATH }}:${{ github.sha }}
|
||||||
|
|
||||||
|
12
.github/workflows/cd-frontend.yml
vendored
12
.github/workflows/cd-frontend.yml
vendored
@@ -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:
|
||||||
|
24
.github/workflows/ci.yml
vendored
24
.github/workflows/ci.yml
vendored
@@ -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
2
Cargo.lock
generated
@@ -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",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "battleship"
|
name = "battleship"
|
||||||
version = "0.1.0"
|
version = "1.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@@ -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,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;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@ export default {
|
|||||||
extend: {},
|
extend: {},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
require('daisyui'),
|
require('daisyui'), // eslint-disable-line
|
||||||
],
|
],
|
||||||
|
|
||||||
daisyui: {
|
daisyui: {
|
||||||
|
Reference in New Issue
Block a user