From e7a0fa3303df0e26ccfa3051cabc3f4a5c717709 Mon Sep 17 00:00:00 2001 From: "S. Amir Mohammad Najafi" Date: Mon, 30 Dec 2024 09:33:15 +0330 Subject: [PATCH] feat: add GitHub Actions workflow for building, linting, and testing the project --- .github/workflows/build-lint-test.yaml | 68 ++++++++++++++++++++++++++ .vscode/settings.json | 5 ++ 2 files changed, 73 insertions(+) create mode 100644 .github/workflows/build-lint-test.yaml create mode 100644 .vscode/settings.json diff --git a/.github/workflows/build-lint-test.yaml b/.github/workflows/build-lint-test.yaml new file mode 100644 index 0000000..e708d76 --- /dev/null +++ b/.github/workflows/build-lint-test.yaml @@ -0,0 +1,68 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: Build, Lint, and Test Project + +on: + workflow_call: + inputs: + node-version: + description: 'Node.js version' + required: true + default: 'lts/*' + type: string + +env: + NODE_VERSION: ${{ inputs.node-version }} + +permissions: + contents: read + +jobs: + main: + name: Build, Lint, and Test Project + runs-on: ubuntu-latest + + steps: + - name: ๐Ÿ“ฅ Checkout repository + uses: actions/checkout@v4 + + - name: ๐Ÿ”ง Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: ๐Ÿ› ๏ธ Setup Node.js Corepack + run: corepack enable + + - name: ๐Ÿ“ฆ Get Yarn Config + id: yarn_config + run: echo "cache_folder=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + + - name: ๐Ÿ—„๏ธ Cache Layer + uses: actions/cache@v4 + with: + path: ${{ steps.yarn_config.outputs.cache_folder }} + key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: ๐Ÿ“ฅ Install Dependencies + run: yarn install --immutable + + - name: ๐Ÿ—ƒ๏ธ Cache Wireit + uses: google/wireit@setup-github-actions-caching/v2 + + - name: ๐Ÿ—๏ธ Build TypeScript + run: yarn build + env: + WIREIT_LOGGER: metrics + + - name: ๐Ÿงน Run ESLint + run: yarn lint + env: + WIREIT_LOGGER: metrics + + - name: ๐Ÿงช Run Tests + run: yarn test + env: + WIREIT_LOGGER: metrics diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..03f04a6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "cSpell.words": [ + "wireit" + ] +} \ No newline at end of file