Skip to content

Commit

Permalink
ci(test.yml): set version v3 to actions/checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Sep 23, 2022
1 parent 7be8459 commit 9dc5341
Showing 1 changed file with 109 additions and 74 deletions.
183 changes: 109 additions & 74 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
on:
"on":
push:
branches:
- master
Expand All @@ -9,40 +9,42 @@ on:
workflow_dispatch: {}
name: Test
jobs:
# use no configuration. Will update existing pull request:
# https://github.com/gr2m/create-or-update-pull-request-action/pull/2
happyPath:
name: "[TEST] Update existing pull request"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
persist-credentials: false
- run: "date > test.txt"
- run: "npm ci"
- run: "npm run build"
- run: date > test.txt
- run: npm ci
- run: npm run build
- uses: ./
id: run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
with:
commit-message: "Just testing [skip ci]"
commit-message: Just testing [skip ci]
- if: ${{ steps.run.outputs.result != 'updated' }}
run: 'echo "Action result output is \"${{ steps.run.outputs.result }}\" but expected \"updated\"" && exit 1'
run: >-
echo "Action result output is \"${{ steps.run.outputs.result }}\" but
expected \"updated\"" && exit 1
- if: ${{ !(steps.run.outputs.pull-request-number > 0) }}
run: 'echo "Action pull-request-number output is \"${{steps.run.outputs.pull-request-number}}\" but expected a number" && exit 1'

run: >-
echo "Action pull-request-number output is
\"${{steps.run.outputs.pull-request-number}}\" but expected a number"
&& exit 1
createNewPullRequest:
name: "[TEST] Create new pull request"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
persist-credentials: false
- run: "date > test.txt"
- run: "npm ci"
- run: "npm run build"
- run: date > test.txt
- run: npm ci
- run: npm run build
- uses: ./
id: run
env:
Expand All @@ -52,118 +54,133 @@ jobs:
title: Test pull request
body: This pull request is part of the CI - please ignore.
branch: test-create-new-pull-request-${{ github.run_number }}
commit-message: "Just testing [skip ci]"
author: "J. Doe <[email protected]>"
commit-message: Just testing [skip ci]
author: J. Doe <[email protected]>
labels: test1, test2
assignees: gr2m
- run: "git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git :test-create-new-pull-request-${{ github.run_number }}"
- run: >-
git push
https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
:test-create-new-pull-request-${{ github.run_number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: ${{ steps.run.outputs.result != 'created' }}
run: 'echo "result output is \"${{ steps.run.outputs.result }}\" but expected \"created\"" && exit 1'
run: >-
echo "result output is \"${{ steps.run.outputs.result }}\" but
expected \"created\"" && exit 1
- if: ${{ !(steps.run.outputs.pull-request-number > 0) }}
run: 'echo "pull-request-number output is \"${{ steps.run.outputs.pull-request-number }}\" but expected a number" && exit 1'

run: >-
echo "pull-request-number output is \"${{
steps.run.outputs.pull-request-number }}\" but expected a number" &&
exit 1
multipleCommits:
name: "[TEST] Create multiple commits"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
persist-credentials: false
- run: "date > file1.txt"
- run: "date > file2.txt"
- run: "npm ci"
- run: "npm run build"
- run: date > file1.txt
- run: date > file2.txt
- run: npm ci
- run: npm run build
- uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
with:
title: Test pull request with multiple commits
body: This pull request is part of the CI - please ignore.
branch: test-create-new-pull-request-with-multiple-commits-${{ github.run_number }}
author: "J. Doe <[email protected]>"
branch: >-
test-create-new-pull-request-with-multiple-commits-${{
github.run_number }}
author: J. Doe <[email protected]>
path: file1.txt
commit-message: "file 1 created [skip ci]"
commit-message: file 1 created [skip ci]
- uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
with:
title: Test pull request
body: This pull request is part of the CI - please ignore.
branch: test-create-new-pull-request-with-multiple-commits-${{ github.run_number }}
author: "J. Doe <[email protected]>"
branch: >-
test-create-new-pull-request-with-multiple-commits-${{
github.run_number }}
author: J. Doe <[email protected]>
path: file2.txt
commit-message: "file 2 created [skip ci]"
commit-message: file 2 created [skip ci]
- uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
with:
title: Test pull request
body: This pull request is part of the CI - please ignore.
branch: test-create-new-pull-request-with-multiple-commits-${{ github.run_number }}
author: "J. Doe <[email protected]>"
branch: >-
test-create-new-pull-request-with-multiple-commits-${{
github.run_number }}
author: J. Doe <[email protected]>
path: does_not_exist.txt
commit-message: "this should fail silently, not commit should be created"
- run: "git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git :test-create-new-pull-request-with-multiple-commits-${{ github.run_number }}"
commit-message: this should fail silently, not commit should be created
- run: >-
git push
https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
:test-create-new-pull-request-with-multiple-commits-${{
github.run_number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

autoMerge:
name: "[TEST] Auto merge"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
persist-credentials: false
- run: "date > test.txt"
- run: "npm ci"
- run: "npm run build"
- run: date > test.txt
- run: npm ci
- run: npm run build
- uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
with:
title: Test pull request for `auto-merge` option
commit-message: "Testing auto-merge"
commit-message: Testing auto-merge
auto-merge: squash
branch: test-auto-merge-${{ github.run_number }}
- run: "git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git :test-auto-merge-${{ github.run_number }}"
- run: >-
git push
https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
:test-auto-merge-${{ github.run_number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# expect to detect changes in a hidden file:
# https://github.com/gr2m/create-or-update-pull-request-action/pull/262
hiddenFile:
name: "[TEST] Create or update pull request for hidden file"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
persist-credentials: false
- run: "date > .github/test.txt"
- run: "npm ci"
- run: "npm run build"
- run: date > .github/test.txt
- run: npm ci
- run: npm run build
- uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
with:
commit-message: "Just testing [skip ci]"

commit-message: Just testing [skip ci]
updatePRTitleAndBody:
name: "[TEST] Update PR title and body"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
persist-credentials: false
- run: "date > test.txt"
- run: "npm ci"
- run: "npm run build"
- run: date > test.txt
- run: npm ci
- run: npm run build
- uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -172,18 +189,20 @@ jobs:
title: Test pull request
body: This pull request is part of the CI - please ignore.
branch: test-update-pr-title-and-body-${{ github.run_number }}
commit-message: "Just testing [skip ci]"
- run: "echo updated >> test.txt"
commit-message: Just testing [skip ci]
- run: echo updated >> test.txt
- uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
with:
title: Skipped Updated test pull request
body: This Skipped updated pull request is part of the CI - please ignore.
body: >-
This Skipped updated pull request is part of the CI - please
ignore.
branch: test-update-pr-title-and-body-${{ github.run_number }}
commit-message: "Just testing [skip ci]"
- run: "echo updated >> test.txt"
commit-message: Just testing [skip ci]
- run: echo updated >> test.txt
- uses: ./
id: run
env:
Expand All @@ -193,7 +212,7 @@ jobs:
title: Updated test pull request
body: This updated pull request is part of the CI - please ignore.
branch: test-update-pr-title-and-body-${{ github.run_number }}
commit-message: "Just testing [skip ci]"
commit-message: Just testing [skip ci]
update-pull-request-title-and-body: true
- uses: octokit/[email protected]
id: get-pull-request
Expand All @@ -204,22 +223,29 @@ jobs:
pull_number: ${{ steps.run.outputs.pull-request-number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: "git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git :test-update-pr-title-and-body-${{ github.run_number }}"
- run: >-
git push
https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
:test-update-pr-title-and-body-${{ github.run_number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: ${{ fromJson(steps.get-pull-request.outputs.data).title != 'Updated test pull request' }}
run: 'echo "Pull request title is \"${{ fromJson(steps.get-pull-request.outputs.data).title }}\" but expected \"Updated test pull request\"" && exit 1'

- if: >-
${{ fromJson(steps.get-pull-request.outputs.data).title != 'Updated
test pull request' }}
run: >-
echo "Pull request title is \"${{
fromJson(steps.get-pull-request.outputs.data).title }}\" but expected
\"Updated test pull request\"" && exit 1
addReviewers:
name: "[TEST] Add Reviewers"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
persist-credentials: false
- run: "date > test.txt"
- run: "npm ci"
- run: "npm run build"
- run: date > test.txt
- run: npm ci
- run: npm run build
- uses: ./
id: run
env:
Expand All @@ -229,7 +255,7 @@ jobs:
title: Test Add Reviewers
body: This pull request is part of the CI - please ignore.
branch: test-add-reviewers-${{ github.run_number }}
commit-message: "Just testing [skip ci]"
commit-message: Just testing [skip ci]
reviewers: gr2m
team_reviewers: test-reviewers
- uses: octokit/[email protected]
Expand All @@ -241,8 +267,17 @@ jobs:
pull_number: ${{ steps.run.outputs.pull-request-number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: "git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git :test-add-reviewers-${{ github.run_number }}"
- run: >-
git push
https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
:test-add-reviewers-${{ github.run_number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: ${{ !contains(toJson(fromJson(steps.get-pull-request.outputs.data).requested_reviewers.*.login), 'gr2m') }}
run: 'echo "Requested reviewers are \"${{ toJson(fromJson(steps.get-pull-request.outputs.data).requested_reviewers.*.login) }}\" but expected \"[\n gr2m \n]\"" && exit 1'
- if: >-
${{
!contains(toJson(fromJson(steps.get-pull-request.outputs.data).requested_reviewers.*.login),
'gr2m') }}
run: >-
echo "Requested reviewers are \"${{
toJson(fromJson(steps.get-pull-request.outputs.data).requested_reviewers.*.login)
}}\" but expected \"[\n gr2m \n]\"" && exit 1

0 comments on commit 9dc5341

Please sign in to comment.