From b29b4d2caf770b6774cab18b843f6d630672f941 Mon Sep 17 00:00:00 2001 From: Thibault Date: Tue, 28 May 2024 12:05:07 +0200 Subject: [PATCH] github: add ci --- .github/workflows/build_test.yml | 80 +++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index b3eebf9..422c4c6 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -9,8 +9,49 @@ on: - "main" jobs: - test: - name: Test + lint_websocket: + name: Lint WebSocket + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '22.2.0' + check-latest: true + - name: yarn install + working-directory: ./websocketServer + run: yarn install --frozen-lockfile + - name: lint + working-directory: ./websocketServer + run: | + prettier --check src test + yarn lint + + build_svelte: + name: Build and lint Svelte + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '22.2.0' + check-latest: true + - name: yarn install + working-directory: ./svelte + run: yarn install --frozen-lockfile + - name: lint + working-directory: ./svelte + run: yarn lint + - name: build + working-directory: ./svelte + run: yarn build + + build_test_rust: + name: Build and test Rust code runs-on: ubuntu-22.04 steps: - name: Checkout @@ -21,3 +62,38 @@ jobs: run: cargo clippy --all-targets --all-features - name: Run tests run: cargo test --all-targets --all-features + + build_and_publish: + name: Build and publish image + needs: [lint_websocket, build_svelte, build_test_rust] + if: github.event_name != 'pull_request' + permissions: + contents: read + packages: write + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get commit short + id: vars + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/tbmc/brainfuck_interpreter:latest + ghcr.io/tbmc/brainfuck_interpreter:${{ steps.vars.outputs.sha_short }}