From 71717c6b026428f4929a92bdb1780da755e316cd Mon Sep 17 00:00:00 2001 From: Matti Nannt Date: Mon, 26 Feb 2024 20:29:28 +0100 Subject: [PATCH] fix: github action (#2131) --- .../actions/dangerous-git-checkout/action.yml | 10 ++++++++ .github/workflows/build-web.yml | 4 +-- .github/workflows/e2e.yml | 1 + .github/workflows/lint.yml | 4 +-- .github/workflows/pr.yml | 25 +++++++++++++++++++ .github/workflows/test.yml | 4 +-- README.md | 2 ++ 7 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 .github/actions/dangerous-git-checkout/action.yml diff --git a/.github/actions/dangerous-git-checkout/action.yml b/.github/actions/dangerous-git-checkout/action.yml new file mode 100644 index 0000000000..48dca84cbe --- /dev/null +++ b/.github/actions/dangerous-git-checkout/action.yml @@ -0,0 +1,10 @@ +name: Dangerous git Checkout +description: "Git Checkout from PR code so we can run checks from forks" +runs: + using: "composite" + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 2 diff --git a/.github/workflows/build-web.yml b/.github/workflows/build-web.yml index afa3a2b5d6..58c8503c6f 100644 --- a/.github/workflows/build-web.yml +++ b/.github/workflows/build-web.yml @@ -8,8 +8,8 @@ jobs: timeout-minutes: 30 steps: - - name: Checkout repo - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + - uses: ./.github/actions/dangerous-git-checkout - name: Setup Node.js 20.x uses: actions/setup-node@v3 diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e4d53a5a8b..fbd1364007 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -9,6 +9,7 @@ jobs: timeout-minutes: 60 steps: - uses: actions/checkout@v3 + - uses: ./.github/actions/dangerous-git-checkout - name: Build & Cache Web Binaries uses: ./.github/actions/cache-build-web diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b29aaf8c15..faff0cd5ec 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,8 +8,8 @@ jobs: timeout-minutes: 15 steps: - - name: Checkout repo - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + - uses: ./.github/actions/dangerous-git-checkout - name: Setup Node.js 18.x uses: actions/setup-node@v3 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d66c769c81..13583d3c72 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -12,23 +12,48 @@ concurrency: cancel-in-progress: true jobs: + changes: + name: Detect changes + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + has-files-requiring-all-checks: ${{ steps.filter.outputs.has-files-requiring-all-checks }} + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/dangerous-git-checkout + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + has-files-requiring-all-checks: + - "!(**.md|.github/CODEOWNERS)" + test: name: Run Tests + needs: [changes] + if: ${{ needs.changes.outputs.has-files-requiring-all-checks == 'true' }} uses: ./.github/workflows/test.yml secrets: inherit lint: name: Run Linters + needs: [changes] + if: ${{ needs.changes.outputs.has-files-requiring-all-checks == 'true' }} uses: ./.github/workflows/lint.yml secrets: inherit build: name: Build Formbricks-web + needs: [changes] + if: ${{ needs.changes.outputs.has-files-requiring-all-checks == 'true' }} uses: ./.github/workflows/build-web.yml secrets: inherit e2e-test: name: Run E2E Tests + needs: [changes] + if: ${{ needs.changes.outputs.has-files-requiring-all-checks == 'true' }} uses: ./.github/workflows/e2e.yml secrets: inherit diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ff7cb9c66..cfd8485b83 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,8 +8,8 @@ jobs: timeout-minutes: 15 steps: - - name: Checkout repo - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + - uses: ./.github/actions/dangerous-git-checkout - name: Setup Node.js 20.x uses: actions/setup-node@v3 diff --git a/README.md b/README.md index cad821384e..b0482dfbe3 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,8 @@ Formbricks is both a free and open source survey platform - and a privacy-first - 🔒 [Auth.js](https://authjs.dev/) - 🧘‍♂️ [Zod](https://zod.dev/) +- +- 🐛 [Vitest](https://vitest.dev/)