From 9833118695fa0a3e5225c352991837a068ff09cc Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Wed, 5 Jun 2024 15:29:28 -0500 Subject: [PATCH 1/3] also test on release branch --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0edb19b5..3dcbcbc5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,7 @@ name: Build and test on: push: - branches: [main] + branches: [main, release] pull_request: types: [opened, reopened, synchronize] From 4a9ae4e8221f3a5bcfc9e299dfed69e850903697 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Wed, 5 Jun 2024 15:30:29 -0500 Subject: [PATCH 2/3] test only for local repo --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3dcbcbc5..d7a080fd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,8 +2,6 @@ name: Build and test on: push: branches: [main, release] - pull_request: - types: [opened, reopened, synchronize] jobs: test: From c0fc5649a1c007ee768680f2c21da298ca4d18b7 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Wed, 5 Jun 2024 15:35:35 -0500 Subject: [PATCH 3/3] create separate file for filter + run previews only if test passes --- .github/workflows/preview.yml | 6 ++++++ .github/workflows/test-previews.yml | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 .github/workflows/test-previews.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index cb73cebe..aa4958ee 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -9,7 +9,13 @@ on: - closed jobs: + test: + uses: key4hep/dmx/.github/workflows/test-previews.yml@main + with: + repository: ${{ github.event.pull_request.head.sha }} + deploy-preview: + needs: test environment: github-pages runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/test-previews.yml b/.github/workflows/test-previews.yml new file mode 100644 index 00000000..f0fad80a --- /dev/null +++ b/.github/workflows/test-previews.yml @@ -0,0 +1,26 @@ +name: Test previews +on: + workflow_call: + inputs: + repository: + required: true + type: string + +jobs: + test: + environment: github-pages + runs-on: ubuntu-latest + steps: + - name: Checkout PR + uses: actions/checkout@v3 + with: + ref: ${{ inputs.repository }} + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: "20.x" + cache: "npm" + - name: Install dependencies + run: npm install + - name: Run tests + run: npm test