From 9dc53416c519db457880ab388d3d836fe209ac67 Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Fri, 23 Sep 2022 12:38:08 -0700 Subject: [PATCH] ci(test.yml): set version v3 to actions/checkout --- .github/workflows/test.yml | 183 ++++++++++++++++++++++--------------- 1 file changed, 109 insertions(+), 74 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1fe32ac2..2453ef7b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -on: +"on": push: branches: - master @@ -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: @@ -52,29 +54,36 @@ 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 " + commit-message: Just testing [skip ci] + author: J. Doe 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 }} @@ -82,10 +91,12 @@ jobs: 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 " + branch: >- + test-create-new-pull-request-with-multiple-commits-${{ + github.run_number }} + author: J. Doe path: file1.txt - commit-message: "file 1 created [skip ci]" + commit-message: file 1 created [skip ci] - uses: ./ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -93,10 +104,12 @@ jobs: 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 " + branch: >- + test-create-new-pull-request-with-multiple-commits-${{ + github.run_number }} + author: J. Doe path: file2.txt - commit-message: "file 2 created [skip ci]" + commit-message: file 2 created [skip ci] - uses: ./ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -104,66 +117,70 @@ jobs: 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 " + branch: >- + test-create-new-pull-request-with-multiple-commits-${{ + github.run_number }} + author: J. Doe 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 }} @@ -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: @@ -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/request-action@v2.x id: get-pull-request @@ -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: @@ -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/request-action@v2.x @@ -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