From 795bb9f369d617ea991eddac7c32158e2053ecaf Mon Sep 17 00:00:00 2001 From: 0xyaco Date: Thu, 18 Jul 2024 18:26:06 -0300 Subject: [PATCH] chore: set up github workflows (#8) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 🤖 Linear Closes GRT-34 ## Description Set up GitHub workflows with the following jobs: - build - lint - test --- .github/workflows/build.yml | 32 +++++++++++++++++++++ .github/workflows/lint.yml | 43 ++++++++++++++++++++++++++++ .github/workflows/main-workflows.yml | 24 ++++++++++++++++ .github/workflows/test.yml | 31 ++++++++++++++++++++ package.json | 5 ++-- turbo.json | 3 +- 6 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/main-workflows.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..dca66da --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,32 @@ +name: Build + +on: + workflow_call: + +jobs: + build: + name: Run Build + runs-on: ubuntu-latest + + steps: + - name: Check out github repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Use PNPM + uses: pnpm/action-setup@v4 + with: + run_install: false + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run Build + run: pnpm build diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..1f993f2 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,43 @@ +name: Lint + +on: + workflow_call: + +jobs: + commitlint: + name: Lint Commit Messages + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: wagoid/commitlint-github-action@v5 + with: + commitDepth: 1 + + lint: + name: Run Linters + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Use PNPM + uses: pnpm/action-setup@v4 + with: + run_install: false + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run Prettier + run: pnpm format + + - name: Run Linter + run: pnpm lint diff --git a/.github/workflows/main-workflows.yml b/.github/workflows/main-workflows.yml new file mode 100644 index 0000000..f93afdc --- /dev/null +++ b/.github/workflows/main-workflows.yml @@ -0,0 +1,24 @@ +name: Main Workflow + +on: + pull_request: + types: [opened, synchronize] + branches: + - dev + - main + +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: true + +jobs: + build: + uses: ./.github/workflows/build.yml + + lint: + uses: ./.github/workflows/lint.yml + needs: build + + test: + uses: ./.github/workflows/test.yml + needs: lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..19573dc --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: Tests + +on: + workflow_call: + +jobs: + unit: + name: Run unit tests + runs-on: ubuntu-latest + steps: + - name: Check out github repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Use PNPM + uses: pnpm/action-setup@v4 + with: + run_install: false + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run tests + run: pnpm test diff --git a/package.json b/package.json index f2b9e60..44c89dd 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,11 @@ "description": "", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", + "test": "turbo run test", "prepare": "husky", "lint": "turbo run lint", - "format": "turbo run format" + "format": "turbo run format", + "build": "turbo run build" }, "keywords": [], "author": "", diff --git a/turbo.json b/turbo.json index 2613654..692f067 100644 --- a/turbo.json +++ b/turbo.json @@ -5,7 +5,8 @@ "lint:fix": {}, "format": {}, "format:fix": {}, - "test": {} + "test": {}, + "build": {} }, "globalDependencies": [".eslintrc", ".prettierrc"] }