From 16ceaa4c40c4255e8c6a0feb1be46d331b59fbb8 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 25 Aug 2023 10:23:54 +0800 Subject: [PATCH] feat: Generify test action --- .github/workflows/generic.test.yml | 40 ++++++++++++++++++++++++++++++ .github/workflows/pr.test.yml | 31 +++-------------------- 2 files changed, 43 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/generic.test.yml diff --git a/.github/workflows/generic.test.yml b/.github/workflows/generic.test.yml new file mode 100644 index 00000000..e7476034 --- /dev/null +++ b/.github/workflows/generic.test.yml @@ -0,0 +1,40 @@ +name: 'Generic: Test' + +on: + workflow_call: + inputs: + plugin_name: + description: 'Plugin name' + required: true + type: string + +jobs: + test: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + cache: gradle + + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Run unit tests + uses: gradle/gradle-build-action@v2 + with: + arguments: build + env: + GITHUB_VERSION: pr${{ github.event.pull_request.number }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Artifact output + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.plugin_name }}-pr${{ github.event.pull_request.number }} + path: build/libs/${{ inputs.plugin_name }}-pr${{ github.event.pull_request.number }}.jar diff --git a/.github/workflows/pr.test.yml b/.github/workflows/pr.test.yml index 69a174f0..721785b1 100644 --- a/.github/workflows/pr.test.yml +++ b/.github/workflows/pr.test.yml @@ -6,31 +6,6 @@ on: jobs: test: - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - cache: gradle - - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 - - - name: Run unit tests - uses: gradle/gradle-build-action@v2 - with: - arguments: build - env: - GITHUB_VERSION: pr${{ github.event.pull_request.number }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Artifact output - uses: actions/upload-artifact@v3 - with: - name: multiverse-core-pr${{ github.event.pull_request.number }} - path: build/libs/multiverse-core-pr${{ github.event.pull_request.number }}.jar + uses: ./.github/workflows/generic.test.yml + with: + plugin_name: multiverse-core