diff --git a/.github/workflows/CI-build.yml b/.github/workflows/CI-build.yml index d8dab97f..7e33f901 100644 --- a/.github/workflows/CI-build.yml +++ b/.github/workflows/CI-build.yml @@ -6,7 +6,6 @@ on: jobs: build: - name: "๐Ÿ”จ Build & Verifx" runs-on: ubuntu-latest # A local build took 20 seconds, CI takes 3 minutes with setup. # Because it's cloud, give it a bit of a buffer and constrain. diff --git a/.github/workflows/CI-pr.yml b/.github/workflows/CI-pr.yml index c073332d..4739009f 100644 --- a/.github/workflows/CI-pr.yml +++ b/.github/workflows/CI-pr.yml @@ -1,7 +1,18 @@ name: "Find PR" on: - workflow_call + workflow_call: + outputs: + found: + value: ${{ jobs.pull_request.outputs.found }} + base_ref: + value: ${{ jobs.pull_request.outputs.base_ref }} + base_sha: + value: ${{ jobs.pull_request.outputs.base_sha }} + head_ref: + value: ${{ jobs.pull_request.outputs.head_ref }} + head_sha: + value: ${{ jobs.pull_request.outputs.head_sha }} jobs: diff --git a/.github/workflows/CI-screenshot-record.yml b/.github/workflows/CI-screenshot-record.yml index 3ebc2972..f5dc94eb 100644 --- a/.github/workflows/CI-screenshot-record.yml +++ b/.github/workflows/CI-screenshot-record.yml @@ -1,12 +1,17 @@ -name: "๐Ÿ“ธ Screenshot Tests / Record" +name: "๐Ÿ“ท Screenshot Tests / ๐Ÿ“ธ Record" on: - workflow_call + workflow_call: + inputs: + ref: + description: "The base branch to compare against." + type: string + required: true + default: "main" jobs: record: - name: "Record" runs-on: ubuntu-latest timeout-minutes: 20 @@ -32,12 +37,12 @@ jobs: echo sdkmanager --install "platforms;android-34" sdkmanager --install "platforms;android-34" - - name: "Checkout ${{ needs.pull_request.outputs.base_ref }} branch in ${{ github.repository }} repository." + - name: "Checkout ${{ inputs.ref }} branch in ${{ github.repository }} repository." uses: actions/checkout@v4 with: - ref: ${{ format('refs/heads/{0}', needs.pull_request.outputs.base_ref) }} + ref: ${{ format('refs/heads/{0}', inputs.ref) }} - - name: "Record screenshots golden values for ${{ needs.pull_request.outputs.base_ref }}." + - name: "Record screenshots golden values for ${{ inputs.ref }}." id: gradle run: > ./gradlew diff --git a/.github/workflows/CI-screenshot-verify.yml b/.github/workflows/CI-screenshot-verify.yml index 9e6b37a1..c727d853 100644 --- a/.github/workflows/CI-screenshot-verify.yml +++ b/.github/workflows/CI-screenshot-verify.yml @@ -1,12 +1,23 @@ -name: "๐Ÿงช Screenshot Tests / Verify" +name: "๐Ÿ“ท Screenshot Tests / ๐Ÿงช Verify" on: - workflow_call + workflow_call: + inputs: + ref: + description: "The head branch to verify against base." + type: string + required: true + + golden_artifact: + description: "The name of the artifact containing the golden values for all modules." + type: string + required: false + default: 'Screenshot Golden Values' jobs: verify: - name: "Verify" + name: "๐Ÿงช Verify" runs-on: ubuntu-latest timeout-minutes: 20 @@ -32,17 +43,17 @@ jobs: echo sdkmanager --install "platforms;android-34" sdkmanager --install "platforms;android-34" - - name: "Checkout ${{ needs.pull_request.outputs.head_ref }} branch in ${{ github.repository }} repository." + - name: "Checkout ${{ inputs.ref }} branch in ${{ github.repository }} repository." uses: actions/checkout@v4 with: - ref: ${{ format('refs/heads/{0}', needs.pull_request.outputs.head_ref) }} + ref: ${{ format('refs/heads/{0}', inputs.ref) }} - - name: "Download 'Screenshot Golden Values' artifact." + - name: "Download '${{ inputs.golden_artifact }}' artifact." uses: actions/download-artifact@v3 with: - name: 'Screenshot Golden Values' + name: '${{ inputs.golden_artifact }}' - - name: "Run screenshot tests to verify ${{ needs.pull_request.outputs.head_ref }}." + - name: "Run screenshot tests to verify ${{ inputs.ref }}." id: gradle run: > ./gradlew diff --git a/.github/workflows/CI-screenshot.yml b/.github/workflows/CI-screenshot.yml new file mode 100644 index 00000000..9583f102 --- /dev/null +++ b/.github/workflows/CI-screenshot.yml @@ -0,0 +1,33 @@ +name: "๐Ÿ“ท Screenshot Tests" + +on: + workflow_call: + inputs: + + base_ref: + description: "The base branch to compare against." + type: string + required: true + default: "main" + + head_ref: + description: "The head branch to verify against base." + type: string + required: true + default: "main" + +jobs: + + record: + name: "๐Ÿ“ธ Record" + uses: ./.github/workflows/CI-screenshot-record.yml + with: + ref: ${{ inputs.base_ref }} + + verify: + name: "๐Ÿงช Verify" + uses: ./.github/workflows/CI-screenshot-verify.yml + with: + ref: ${{ inputs.head_ref }} + needs: + - record diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 54809dd7..3991b51e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,7 +14,7 @@ jobs: uses: TWiStErRob/github-workflows/.github/workflows/validate.yml@v1 build: - name: "๐Ÿ”จ Build & Verifz" + name: "๐Ÿ”จ Build & Verify" uses: ./.github/workflows/CI-build.yml needs: - validate @@ -25,22 +25,14 @@ jobs: # Don't execute on main, it'll never be PR'd. if: github.ref != 'refs/heads/main' && (success() || failure()) - record-base: + screenshot: name: "๐Ÿ“ธ Screenshot Tests" - uses: ./.github/workflows/CI-screenshot-record.yml + uses: ./.github/workflows/CI-screenshot.yml + with: + base_ref: ${{ needs.pull_request.outputs.base_ref }} + head_ref: ${{ needs.pull_request.outputs.head_ref }} needs: + - validate - pull_request # Don't execute on main, as it'll just verify against itself. if: github.ref != 'refs/heads/main' && needs.pull_request.outputs.found == 'true' - - verify-pr: - name: "๐Ÿ“ธ Screenshot Tests" - uses: ./.github/workflows/CI-screenshot-verify.yml - needs: - - validate - # If build fails, there's not much point in running screenshot tests. - - build - # Need to run after recording base branch golden values to compare against them. - - record-base - - pull_request - if: needs.pull_request.outputs.found == 'true'