Skip to content

Format by tkhs0604 - DroidKaigi:kenken/implement_expect_actual #1945

Format by tkhs0604 - DroidKaigi:kenken/implement_expect_actual

Format by tkhs0604 - DroidKaigi:kenken/implement_expect_actual #1945

Workflow file for this run

# Run after-hooks of workflow executions. Changes to this workflow file enables only if it's available on the default branch.
#
# Please note that we should not checkout the target code because it contains unverified changes.
name: Workflow Hook
on:
workflow_run:
workflows:
- UnitTest
- Format
- iOS Lint
types:
- completed
# Disable all permissions. We have to enable required permissions at job-level.
permissions: {}
run-name: ${{ github.event.workflow_run.name }} - ${{ github.event.workflow_run.head_repository.owner.login }}:${{ github.event.workflow_run.head_branch }}
# Restrict the concurrency on a pair of a repository owner and a branch.
concurrency:
group: workflow-hook-${{ github.event.workflow_run.head_repository.owner.login }}:${{ github.event.workflow_run.head_branch }}-${{ github.event.workflow_run.name }}
cancel-in-progress: true
jobs:
# Run every executions of workflows specified in workflow_run#workflows
# This job will expose an associated pull request if exists.
linked-pull-request:
# Run this job only when it's required.
# Array-literal is not available in Actions so we have to transform a json string into an array.
if: >
contains(fromJSON('["failure"]'), github.event.workflow_run.conclusion) &&
contains(fromJSON('["Format"]'), github.event.workflow.name) ||
contains(fromJSON('["success", "failure"]'), github.event.workflow_run.conclusion) &&
contains(fromJSON('["UnitTest"]'), github.event.workflow.name) ||
contains(fromJSON('["failure"]'), github.event.workflow_run.conclusion) &&
contains(fromJSON('["iOS Lint"]'), github.event.workflow.name)
permissions:
pull-requests: read # for listing pull requests
timeout-minutes: 2
outputs:
pull-request: ${{ steps.linked-pull-request.outputs.entity }} # pull request entity (string)
runs-on: ubuntu-latest
steps:
- id: linked-pull-request
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
script: |
// Get the latest pull request
const headBranch = '${{ format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch) }}';
const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: headBranch,
direction: 'desc',
sort: 'updated',
per_page: 1
});
if (pulls.length === 0) {
core.warning('No pull request is found.');
} else {
core.setOutput('entity', pulls[0]);
}
# Run every executions of Format workflow. (failure only)
after-Format:
needs:
- linked-pull-request
if: >
github.event.workflow.name == 'Format' &&
needs.linked-pull-request.outputs.pull-request &&
fromJSON(needs.linked-pull-request.outputs.pull-request).number
permissions:
pull-requests: write # for creating a comment on pull requests
timeout-minutes: 2
runs-on: ubuntu-latest
steps:
- uses: marocchino/sticky-pull-request-comment@f61b6cf21ef2fcc468f4345cdfcc9bda741d2343 # v2.6.2
with:
header: ping-format
number: ${{ fromJSON(needs.linked-pull-request.outputs.pull-request).number }}
recreate: true
message: >
Hi @${{ github.event.workflow_run.actor.login }}!
Codes seem to be unformatted. To resolve this issue, please run `./gradlew spotlessKotlinApply` and fix the results of ./gradlew lintDebug..
Thank you for your contribution.
# Run every executions of UnitTest workflow. (always)
after-UnitTest:
needs:
- linked-pull-request
if: >
github.event.workflow.name == 'UnitTest' &&
needs.linked-pull-request.outputs.pull-request &&
fromJSON(needs.linked-pull-request.outputs.pull-request).number
permissions:
actions: read # for downloading artifacts
contents: read # for EnricoMi/publish-unit-test-result-action (we can remove this safely after making this repo public)
issues: read # for EnricoMi/publish-unit-test-result-action (we can remove this safely after making this repo public)
checks: write # for EnricoMi/publish-unit-test-result-action
pull-requests: write # for creating a comment on pull requests
timeout-minutes: 2
runs-on: ubuntu-latest
steps:
- uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2.27.0
with:
run_id: ${{ github.event.workflow_run.id }}
name: test-results
path: .test-results
- uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2.27.0
with:
run_id: ${{ github.event.workflow_run.id }}
name: event-payload
path: .event-payload
- uses: EnricoMi/publish-unit-test-result-action@4e7013f9576bd22ffdae979dc6e68cb9ec2aeece # v2.7.0
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: .event-payload/event.json
event_name: ${{ github.event.workflow_run.event }}
files: |
.test-results/**/*.xml
# Run every executions of iOS Lint workflow. (failure only)
after-iOSLint:
needs:
- linked-pull-request
if: >
github.event.workflow.name == 'iOS Lint' &&
needs.linked-pull-request.outputs.pull-request &&
fromJSON(needs.linked-pull-request.outputs.pull-request).number
permissions:
pull-requests: write # for creating a comment on pull requests
timeout-minutes: 2
runs-on: ubuntu-latest
steps:
- uses: marocchino/sticky-pull-request-comment@f61b6cf21ef2fcc468f4345cdfcc9bda741d2343 # v2.6.2
with:
header: ping-format
number: ${{ fromJSON(needs.linked-pull-request.outputs.pull-request).number }}
recreate: true
message: >
Hi @${{ github.event.workflow_run.actor.login }}!
Codes seem to have violations. Please run `cd app-ios && swiftlint --fix` to fix this issue.
Thank you for your contribution.