From 4a0964dce558cd19ea376731a48502c9f601c2cb Mon Sep 17 00:00:00 2001 From: isra el Date: Sun, 30 Mar 2025 10:53:26 +0300 Subject: [PATCH] infra: add workflow for building and testing --- .github/workflows/build-and-test.yaml | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/build-and-test.yaml diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml new file mode 100644 index 0000000..fc9b5bc --- /dev/null +++ b/.github/workflows/build-and-test.yaml @@ -0,0 +1,64 @@ +name: Build and Test + +on: + push: + paths: + - 'api/**' + - 'web/**' + - '.github/workflows/build-and-test.yaml' + + workflow_dispatch: + inputs: + branch: + description: 'Branch to run workflow on' + required: true + default: 'main' + type: string + +jobs: + build-and-test: + name: Build and Test + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }} + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache + uses: actions/cache@v3 + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Build and test API + run: | + cd api + pnpm install + pnpm run build + pnpm test + + - name: Build web + run: | + cd web + pnpm install + pnpm run build \ No newline at end of file