From 5015cbcd6c5c8993752cf0d57d03603ec4087e25 Mon Sep 17 00:00:00 2001 From: takumi-saito Date: Thu, 8 Feb 2024 02:11:30 +0900 Subject: [PATCH 01/13] =?UTF-8?q?reg-suit=E3=81=AEactions=E4=BD=9C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/reg.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/reg.yml diff --git a/.github/workflows/reg.yml b/.github/workflows/reg.yml new file mode 100644 index 00000000..f563ad37 --- /dev/null +++ b/.github/workflows/reg.yml @@ -0,0 +1,35 @@ +name: Visual Regression Testing + +on: [push] + +jobs: + reg-screenshot-test: + runs-on: ubuntu-latest + timeout-minutes: 20 + + permissions: + contents: read # for clone + actions: write # for upload-artifact + + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Set up JDK 17 + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + with: + distribution: temurin + java-version: 17 + + # Better than caching and/or extensions of actions/setup-java + - name: Setup Gradle + uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0 + with: + gradle-version: wrapper + + - name: create the current snapshot + run: | + ./gradlew recordRoborazziDebug --stacktrace + - name: run reg + run: | + yarn run reg-suit run --test \ No newline at end of file From f63ce93b6debf1e3c1ab498c734a636370660a41 Mon Sep 17 00:00:00 2001 From: takumi-saito Date: Thu, 8 Feb 2024 02:12:01 +0900 Subject: [PATCH 02/13] =?UTF-8?q?=E4=BB=96=E3=81=AEactions=E3=82=92?= =?UTF-8?q?=E4=B8=80=E6=97=A6=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=A2?= =?UTF-8?q?=E3=82=A6=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CompareScreenshot.yml | 160 +++++----- .../workflows/CompareScreenshotComment.yml | 300 +++++++++--------- .github/workflows/StoreScreenshot.yml | 130 ++++---- 3 files changed, 295 insertions(+), 295 deletions(-) diff --git a/.github/workflows/CompareScreenshot.yml b/.github/workflows/CompareScreenshot.yml index c334046a..09d4aa48 100644 --- a/.github/workflows/CompareScreenshot.yml +++ b/.github/workflows/CompareScreenshot.yml @@ -1,80 +1,80 @@ -name: CompareScreenshot - -on: - push: - branches: - - main - pull_request: - -permissions: {} - -jobs: - compare-screenshot-test: - runs-on: ubuntu-latest - timeout-minutes: 20 - - permissions: - contents: read # for clone - actions: write # for upload-artifact - - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Set up JDK 17 - uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 - with: - distribution: temurin - java-version: 17 - - - name: Setup Gradle - uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0 - with: - gradle-version: wrapper - - # Download artifacts - - uses: dawidd6/action-download-artifact@v2 - continue-on-error: true - with: - name: screenshot - workflow: StoreScreenshot.yml - branch: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.event.repository.default_branch }} - - - name: compare screenshot test - id: compare-screenshot-test - run: | - ./gradlew compareRoborazziDebug --stacktrace - - - uses: actions/upload-artifact@v3 - if: ${{ always() }} - with: - name: screenshot-diff - path: | - **/build/outputs/roborazzi - retention-days: 30 - - - uses: actions/upload-artifact@v3 - if: ${{ always() }} - with: - name: screenshot-diff-reports - path: | - **/build/reports - retention-days: 30 - - - uses: actions/upload-artifact@v3 - if: ${{ always() }} - with: - name: screenshot-diff-test-results - path: | - **/build/test-results - retention-days: 30 - - - name: Save PR number - if: ${{ github.event_name == 'pull_request' }} - run: | - mkdir -p ./pr - echo ${{ github.event.number }} > ./pr/NR - - uses: actions/upload-artifact@v3 - with: - name: pr - path: pr/ \ No newline at end of file +#name: CompareScreenshot +# +#on: +# push: +# branches: +# - main +# pull_request: +# +#permissions: {} +# +#jobs: +# compare-screenshot-test: +# runs-on: ubuntu-latest +# timeout-minutes: 20 +# +# permissions: +# contents: read # for clone +# actions: write # for upload-artifact +# +# steps: +# - name: Checkout +# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 +# +# - name: Set up JDK 17 +# uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 +# with: +# distribution: temurin +# java-version: 17 +# +# - name: Setup Gradle +# uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0 +# with: +# gradle-version: wrapper +# +# # Download artifacts +# - uses: dawidd6/action-download-artifact@v2 +# continue-on-error: true +# with: +# name: screenshot +# workflow: StoreScreenshot.yml +# branch: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.event.repository.default_branch }} +# +# - name: compare screenshot test +# id: compare-screenshot-test +# run: | +# ./gradlew compareRoborazziDebug --stacktrace +# +# - uses: actions/upload-artifact@v3 +# if: ${{ always() }} +# with: +# name: screenshot-diff +# path: | +# **/build/outputs/roborazzi +# retention-days: 30 +# +# - uses: actions/upload-artifact@v3 +# if: ${{ always() }} +# with: +# name: screenshot-diff-reports +# path: | +# **/build/reports +# retention-days: 30 +# +# - uses: actions/upload-artifact@v3 +# if: ${{ always() }} +# with: +# name: screenshot-diff-test-results +# path: | +# **/build/test-results +# retention-days: 30 +# +# - name: Save PR number +# if: ${{ github.event_name == 'pull_request' }} +# run: | +# mkdir -p ./pr +# echo ${{ github.event.number }} > ./pr/NR +# - uses: actions/upload-artifact@v3 +# with: +# name: pr +# path: pr/ \ No newline at end of file diff --git a/.github/workflows/CompareScreenshotComment.yml b/.github/workflows/CompareScreenshotComment.yml index 620cdd7d..23fbaf42 100644 --- a/.github/workflows/CompareScreenshotComment.yml +++ b/.github/workflows/CompareScreenshotComment.yml @@ -1,150 +1,150 @@ -name: Screenshot compare comment - -on: - workflow_run: - workflows: - - CompareScreenshot - types: - - completed - -permissions: { } - -jobs: - Comment-CompareScreenshot: - if: > - github.event.workflow_run.event == 'pull_request' && - github.event.workflow_run.conclusion == 'success' - - timeout-minutes: 2 - - permissions: - actions: read # for downloading artifacts - contents: write # for pushing screenshot-diff to companion branch - pull-requests: write # for creating a comment on pull requests - - runs-on: ubuntu-latest - - steps: - - uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2.27.0 - with: - name: pr - run_id: ${{ github.event.workflow_run.id }} - - id: get-pull-request-number - name: Get pull request number - shell: bash - run: | - echo "pull_request_number=$(cat NR)" >> "$GITHUB_OUTPUT" - - name: main checkout - id: checkout-main - uses: actions/checkout@v4 - with: - ref: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.event.pull_request.base.ref || github.event.repository.default_branch }} - - id: switch-companion-branch - env: - BRANCH_NAME: companion_${{ github.event.workflow_run.head_branch }} - run: | - # orphan means it will create no history branch - git branch -D "$BRANCH_NAME" || true - git checkout --orphan "$BRANCH_NAME" - git rm -rf . - - uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2.27.0 - with: - run_id: ${{ github.event.workflow_run.id }} - name: screenshot-diff - path: screenshot-diff - - id: check-if-there-are-valid-files - name: Check if there are valid files - shell: bash - run: | - # Find all the files ending with _compare.png - mapfile -t files_to_add < <(find . -type f -name "*_compare.png") - - # Check for invalid file names and add only valid ones - exist_valid_files="false" - for file in "${files_to_add[@]}"; do - if [[ $file =~ ^[a-zA-Z0-9_./-]+$ ]]; then - exist_valid_files="true" - break - fi - done - echo "exist_valid_files=$exist_valid_files" >> "$GITHUB_OUTPUT" - - id: push-screenshot-diff - shell: bash - if: steps.check-if-there-are-valid-files.outputs.exist_valid_files == 'true' - env: - BRANCH_NAME: companion_${{ github.event.workflow_run.head_branch }} - run: | - # Find all the files ending with _compare.png - files_to_add=$(find . -type f -name "*_compare.png") - - # Check for invalid file names and add only valid ones - for file in $files_to_add; do - if [[ "$file" =~ ^[a-zA-Z0-9_./-]+$ ]]; then - git add "$file" - fi - done - git config --global user.name ScreenshotBot - git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com - git commit -m "Add screenshot diff" - git push origin HEAD:"$BRANCH_NAME" -f - - id: generate-diff-reports - name: Generate diff reports - if: steps.check-if-there-are-valid-files.outputs.exist_valid_files == 'true' - env: - BRANCH_NAME: companion_${{ github.event.workflow_run.head_branch }} - shell: bash - run: | - # Find all the files ending with _compare.png in roborazzi folder - files=$(find . -type f -name "*_compare.png" | grep "roborazzi/" | grep -E "^[a-zA-Z0-9_./-]+$") - delimiter="$(openssl rand -hex 8)" - { - echo "reports<<${delimiter}" - - # Create markdown table header - echo "Snapshot diff report vs base branch: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.event.pull_request.base.ref || github.event.repository.default_branch }}" - echo "| File name | Image |" - echo "|-------|-------|" - } >> "$GITHUB_OUTPUT" - - # Iterate over the files and create table rows - for file in $files; do - # Get the file name and insert newlines every 20 characters - fileName=$(basename "$file" | sed -r 's/(.{20})/\1
/g') - echo "| [$fileName](https://github.com/${{ github.repository }}/blob/$BRANCH_NAME/$file) | ![](https://github.com/${{ github.repository }}/blob/$BRANCH_NAME/$file?raw=true) |" >> "$GITHUB_OUTPUT" - done - echo "${delimiter}" >> "$GITHUB_OUTPUT" - - name: Find Comment - uses: peter-evans/find-comment@v2 - id: fc - if: steps.generate-diff-reports.outputs.reports != '' - with: - issue-number: ${{ steps.get-pull-request-number.outputs.pull_request_number }} - comment-author: 'github-actions[bot]' - body-includes: Snapshot diff report - - - name: Add or update comment on PR - uses: peter-evans/create-or-update-comment@v3 - if: steps.generate-diff-reports.outputs.reports != '' - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ steps.get-pull-request-number.outputs.pull_request_number }} - body: ${{ steps.generate-diff-reports.outputs.reports }} - edit-mode: replace - - - name: Cleanup outdated companion branches - run: | - # Find outdated companion branches with last commit date - git branch -r --format="%(refname:lstrip=3)" | grep companion_ | while read -r branch; do - last_commit_date_timestamp=$(git log -1 --format=%ct "origin/$branch") - now_timestamp=$(date +%s) - # Delete branch if it's older than 1 month - # if [ $((now_timestamp - last_commit_date_timestamp)) -gt 2592000 ]; then - # For testing purpose, delete branch if it's older than 1 second - echo "branch: $branch now_timestamp: $now_timestamp last_commit_date_timestamp: $last_commit_date_timestamp" - if [ $((now_timestamp - last_commit_date_timestamp)) -gt 1 ]; then - # Comment out for demonstration purpose - echo "Deleting $branch" - - # git push origin --delete "$branch" - fi - done \ No newline at end of file +#name: Screenshot compare comment +# +#on: +# workflow_run: +# workflows: +# - CompareScreenshot +# types: +# - completed +# +#permissions: { } +# +#jobs: +# Comment-CompareScreenshot: +# if: > +# github.event.workflow_run.event == 'pull_request' && +# github.event.workflow_run.conclusion == 'success' +# +# timeout-minutes: 2 +# +# permissions: +# actions: read # for downloading artifacts +# contents: write # for pushing screenshot-diff to companion branch +# pull-requests: write # for creating a comment on pull requests +# +# runs-on: ubuntu-latest +# +# steps: +# - uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2.27.0 +# with: +# name: pr +# run_id: ${{ github.event.workflow_run.id }} +# - id: get-pull-request-number +# name: Get pull request number +# shell: bash +# run: | +# echo "pull_request_number=$(cat NR)" >> "$GITHUB_OUTPUT" +# - name: main checkout +# id: checkout-main +# uses: actions/checkout@v4 +# with: +# ref: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.event.pull_request.base.ref || github.event.repository.default_branch }} +# - id: switch-companion-branch +# env: +# BRANCH_NAME: companion_${{ github.event.workflow_run.head_branch }} +# run: | +# # orphan means it will create no history branch +# git branch -D "$BRANCH_NAME" || true +# git checkout --orphan "$BRANCH_NAME" +# git rm -rf . +# - uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2.27.0 +# with: +# run_id: ${{ github.event.workflow_run.id }} +# name: screenshot-diff +# path: screenshot-diff +# - id: check-if-there-are-valid-files +# name: Check if there are valid files +# shell: bash +# run: | +# # Find all the files ending with _compare.png +# mapfile -t files_to_add < <(find . -type f -name "*_compare.png") +# +# # Check for invalid file names and add only valid ones +# exist_valid_files="false" +# for file in "${files_to_add[@]}"; do +# if [[ $file =~ ^[a-zA-Z0-9_./-]+$ ]]; then +# exist_valid_files="true" +# break +# fi +# done +# echo "exist_valid_files=$exist_valid_files" >> "$GITHUB_OUTPUT" +# - id: push-screenshot-diff +# shell: bash +# if: steps.check-if-there-are-valid-files.outputs.exist_valid_files == 'true' +# env: +# BRANCH_NAME: companion_${{ github.event.workflow_run.head_branch }} +# run: | +# # Find all the files ending with _compare.png +# files_to_add=$(find . -type f -name "*_compare.png") +# +# # Check for invalid file names and add only valid ones +# for file in $files_to_add; do +# if [[ "$file" =~ ^[a-zA-Z0-9_./-]+$ ]]; then +# git add "$file" +# fi +# done +# git config --global user.name ScreenshotBot +# git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com +# git commit -m "Add screenshot diff" +# git push origin HEAD:"$BRANCH_NAME" -f +# - id: generate-diff-reports +# name: Generate diff reports +# if: steps.check-if-there-are-valid-files.outputs.exist_valid_files == 'true' +# env: +# BRANCH_NAME: companion_${{ github.event.workflow_run.head_branch }} +# shell: bash +# run: | +# # Find all the files ending with _compare.png in roborazzi folder +# files=$(find . -type f -name "*_compare.png" | grep "roborazzi/" | grep -E "^[a-zA-Z0-9_./-]+$") +# delimiter="$(openssl rand -hex 8)" +# { +# echo "reports<<${delimiter}" +# +# # Create markdown table header +# echo "Snapshot diff report vs base branch: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.event.pull_request.base.ref || github.event.repository.default_branch }}" +# echo "| File name | Image |" +# echo "|-------|-------|" +# } >> "$GITHUB_OUTPUT" +# +# # Iterate over the files and create table rows +# for file in $files; do +# # Get the file name and insert newlines every 20 characters +# fileName=$(basename "$file" | sed -r 's/(.{20})/\1
/g') +# echo "| [$fileName](https://github.com/${{ github.repository }}/blob/$BRANCH_NAME/$file) | ![](https://github.com/${{ github.repository }}/blob/$BRANCH_NAME/$file?raw=true) |" >> "$GITHUB_OUTPUT" +# done +# echo "${delimiter}" >> "$GITHUB_OUTPUT" +# - name: Find Comment +# uses: peter-evans/find-comment@v2 +# id: fc +# if: steps.generate-diff-reports.outputs.reports != '' +# with: +# issue-number: ${{ steps.get-pull-request-number.outputs.pull_request_number }} +# comment-author: 'github-actions[bot]' +# body-includes: Snapshot diff report +# +# - name: Add or update comment on PR +# uses: peter-evans/create-or-update-comment@v3 +# if: steps.generate-diff-reports.outputs.reports != '' +# with: +# comment-id: ${{ steps.fc.outputs.comment-id }} +# issue-number: ${{ steps.get-pull-request-number.outputs.pull_request_number }} +# body: ${{ steps.generate-diff-reports.outputs.reports }} +# edit-mode: replace +# +# - name: Cleanup outdated companion branches +# run: | +# # Find outdated companion branches with last commit date +# git branch -r --format="%(refname:lstrip=3)" | grep companion_ | while read -r branch; do +# last_commit_date_timestamp=$(git log -1 --format=%ct "origin/$branch") +# now_timestamp=$(date +%s) +# # Delete branch if it's older than 1 month +# # if [ $((now_timestamp - last_commit_date_timestamp)) -gt 2592000 ]; then +# # For testing purpose, delete branch if it's older than 1 second +# echo "branch: $branch now_timestamp: $now_timestamp last_commit_date_timestamp: $last_commit_date_timestamp" +# if [ $((now_timestamp - last_commit_date_timestamp)) -gt 1 ]; then +# # Comment out for demonstration purpose +# echo "Deleting $branch" +# +# # git push origin --delete "$branch" +# fi +# done \ No newline at end of file diff --git a/.github/workflows/StoreScreenshot.yml b/.github/workflows/StoreScreenshot.yml index afe9f5c7..e4d41e03 100644 --- a/.github/workflows/StoreScreenshot.yml +++ b/.github/workflows/StoreScreenshot.yml @@ -1,65 +1,65 @@ -name: StoreScreenshot - -# プルリクエストのスクリーンショットを保存するワークフロー -on: - push: - branches: - - main - pull_request: - -permissions: {} - -jobs: - store-screenshot-test: - runs-on: ubuntu-latest - timeout-minutes: 20 - - permissions: - contents: read # for clone - actions: write # for upload-artifact - - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Set up JDK 17 - uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 - with: - distribution: temurin - java-version: 17 - - # Better than caching and/or extensions of actions/setup-java - - name: Setup Gradle - uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0 - with: - gradle-version: wrapper - - - name: record screenshot - id: record-test - run: | - # Use --rerun-tasks to disable cache for test task - ./gradlew recordRoborazziDebug --stacktrace --rerun-tasks - # Upload artifacts - - uses: actions/upload-artifact@v3 - if: ${{ always() }} - with: - name: screenshot - path: | - **/build/outputs/roborazzi - retention-days: 30 - # Upload reports - - uses: actions/upload-artifact@v3 - if: ${{ always() }} - with: - name: screenshot-reports - path: | - **/build/reports - retention-days: 30 - # Upload test results - - uses: actions/upload-artifact@v3 - if: ${{ always() }} - with: - name: screenshot-test-results - path: | - **/build/test-results - retention-days: 30 \ No newline at end of file +#name: StoreScreenshot +# +## プルリクエストのスクリーンショットを保存するワークフロー +#on: +# push: +# branches: +# - main +# pull_request: +# +#permissions: {} +# +#jobs: +# store-screenshot-test: +# runs-on: ubuntu-latest +# timeout-minutes: 20 +# +# permissions: +# contents: read # for clone +# actions: write # for upload-artifact +# +# steps: +# - name: Checkout +# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 +# +# - name: Set up JDK 17 +# uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 +# with: +# distribution: temurin +# java-version: 17 +# +# # Better than caching and/or extensions of actions/setup-java +# - name: Setup Gradle +# uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0 +# with: +# gradle-version: wrapper +# +# - name: record screenshot +# id: record-test +# run: | +# # Use --rerun-tasks to disable cache for test task +# ./gradlew recordRoborazziDebug --stacktrace --rerun-tasks +# # Upload artifacts +# - uses: actions/upload-artifact@v3 +# if: ${{ always() }} +# with: +# name: screenshot +# path: | +# **/build/outputs/roborazzi +# retention-days: 30 +# # Upload reports +# - uses: actions/upload-artifact@v3 +# if: ${{ always() }} +# with: +# name: screenshot-reports +# path: | +# **/build/reports +# retention-days: 30 +# # Upload test results +# - uses: actions/upload-artifact@v3 +# if: ${{ always() }} +# with: +# name: screenshot-test-results +# path: | +# **/build/test-results +# retention-days: 30 \ No newline at end of file From c63b651776edc35af4f6b553c3a24258de4f31ae Mon Sep 17 00:00:00 2001 From: takumi-saito Date: Thu, 8 Feb 2024 02:27:07 +0900 Subject: [PATCH 03/13] rename --- .../workflows/{CompareScreenshot.yml => CompareScreenshot.yml.bk} | 0 ...mpareScreenshotComment.yml => CompareScreenshotComment.yml.bk} | 0 .github/workflows/{StoreScreenshot.yml => StoreScreenshot.yml.bk} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{CompareScreenshot.yml => CompareScreenshot.yml.bk} (100%) rename .github/workflows/{CompareScreenshotComment.yml => CompareScreenshotComment.yml.bk} (100%) rename .github/workflows/{StoreScreenshot.yml => StoreScreenshot.yml.bk} (100%) diff --git a/.github/workflows/CompareScreenshot.yml b/.github/workflows/CompareScreenshot.yml.bk similarity index 100% rename from .github/workflows/CompareScreenshot.yml rename to .github/workflows/CompareScreenshot.yml.bk diff --git a/.github/workflows/CompareScreenshotComment.yml b/.github/workflows/CompareScreenshotComment.yml.bk similarity index 100% rename from .github/workflows/CompareScreenshotComment.yml rename to .github/workflows/CompareScreenshotComment.yml.bk diff --git a/.github/workflows/StoreScreenshot.yml b/.github/workflows/StoreScreenshot.yml.bk similarity index 100% rename from .github/workflows/StoreScreenshot.yml rename to .github/workflows/StoreScreenshot.yml.bk From 827f652ca5d0e25cc4df2a1b1dddccef527cd1af Mon Sep 17 00:00:00 2001 From: takumi-saito Date: Thu, 8 Feb 2024 02:31:09 +0900 Subject: [PATCH 04/13] add reg-suit actions sample --- .github/workflows/reg.yml | 12 ++++++++--- .github/workflows/reg2.yml | 41 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/reg2.yml diff --git a/.github/workflows/reg.yml b/.github/workflows/reg.yml index f563ad37..9afbf11b 100644 --- a/.github/workflows/reg.yml +++ b/.github/workflows/reg.yml @@ -1,6 +1,11 @@ name: Visual Regression Testing -on: [push] +## プルリクエストのスクリーンショットを保存するワークフロー +on: + push: + branches: + - main + pull_request: jobs: reg-screenshot-test: @@ -8,8 +13,9 @@ jobs: timeout-minutes: 20 permissions: - contents: read # for clone - actions: write # for upload-artifact + actions: read # for downloading artifacts + contents: write # for pushing screenshot-diff to companion branch + pull-requests: write # for creating a comment on pull requests steps: - name: Checkout diff --git a/.github/workflows/reg2.yml b/.github/workflows/reg2.yml new file mode 100644 index 00000000..d70d96b5 --- /dev/null +++ b/.github/workflows/reg2.yml @@ -0,0 +1,41 @@ +# .github/workflows/reg.yml + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + permissions: + actions: read # for downloading artifacts + contents: write # for pushing screenshot-diff to companion branch + pull-requests: write # for creating a comment on pull requests + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up JDK 17 + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + with: + distribution: temurin + java-version: 17 + - name: Use Node.js v10 + uses: actions/setup-node@v1 + with: + node-version: "10.x" + - name: npm install, build, and test + run: | + npm i + # Better than caching and/or extensions of actions/setup-java + - name: Setup Gradle + uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0 + with: + gradle-version: wrapper + - name: workaround for detached HEAD + run: | + git checkout ${GITHUB_REF#refs/heads/} || git checkout -b ${GITHUB_REF#refs/heads/} && git pull + - name: create the current snapshot + run: | + ./gradlew recordRoborazziDebug --stacktrace + - name: run reg-suit + run: | + npx reg-suit run \ No newline at end of file From c964b4f0820011dfbf796d96681ed52f91d64865 Mon Sep 17 00:00:00 2001 From: takumi-saito Date: Thu, 8 Feb 2024 02:40:12 +0900 Subject: [PATCH 05/13] fix --- .github/workflows/reg.yml | 5 +++-- .github/workflows/reg2.yml | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/reg.yml b/.github/workflows/reg.yml index 9afbf11b..128c5501 100644 --- a/.github/workflows/reg.yml +++ b/.github/workflows/reg.yml @@ -2,10 +2,11 @@ name: Visual Regression Testing ## プルリクエストのスクリーンショットを保存するワークフロー on: - push: + pull_request: + types: + - opened branches: - main - pull_request: jobs: reg-screenshot-test: diff --git a/.github/workflows/reg2.yml b/.github/workflows/reg2.yml index d70d96b5..d2bd8455 100644 --- a/.github/workflows/reg2.yml +++ b/.github/workflows/reg2.yml @@ -1,6 +1,11 @@ # .github/workflows/reg.yml -on: [push] +on: + pull_request: + types: + - opened + branches: + - main jobs: build: @@ -18,10 +23,10 @@ jobs: with: distribution: temurin java-version: 17 - - name: Use Node.js v10 + - name: Use Node.js v12 uses: actions/setup-node@v1 with: - node-version: "10.x" + node-version: "12.x" - name: npm install, build, and test run: | npm i From 7937a736319733cdab473b14d480bdff367095d6 Mon Sep 17 00:00:00 2001 From: takumi-saito Date: Thu, 8 Feb 2024 02:42:23 +0900 Subject: [PATCH 06/13] fix --- .github/workflows/reg.yml | 5 +---- .github/workflows/reg2.yml | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/reg.yml b/.github/workflows/reg.yml index 128c5501..e4a33f90 100644 --- a/.github/workflows/reg.yml +++ b/.github/workflows/reg.yml @@ -3,10 +3,7 @@ name: Visual Regression Testing ## プルリクエストのスクリーンショットを保存するワークフロー on: pull_request: - types: - - opened - branches: - - main + types: [opened, reopened] jobs: reg-screenshot-test: diff --git a/.github/workflows/reg2.yml b/.github/workflows/reg2.yml index d2bd8455..b15ff3a7 100644 --- a/.github/workflows/reg2.yml +++ b/.github/workflows/reg2.yml @@ -2,10 +2,7 @@ on: pull_request: - types: - - opened - branches: - - main + types: [opened, reopened] jobs: build: From d394465de262c688b8f38c5b6c06241f5891fa60 Mon Sep 17 00:00:00 2001 From: takumi-saito Date: Thu, 8 Feb 2024 02:46:40 +0900 Subject: [PATCH 07/13] fix regconfig.json --- regconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/regconfig.json b/regconfig.json index 1e100be8..b741e4b6 100644 --- a/regconfig.json +++ b/regconfig.json @@ -9,7 +9,6 @@ "addIgnore": true }, "plugins": { - "reg-keygen-git-hash-plugin": {}, "reg-notify-github-plugin": { "prComment": true, "prCommentBehavior": "default", From 1b1cd36f8c78e512aa38e36b32911f784c19e675 Mon Sep 17 00:00:00 2001 From: takumi-saito Date: Thu, 8 Feb 2024 02:47:57 +0900 Subject: [PATCH 08/13] fix --- .github/workflows/reg2.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reg2.yml b/.github/workflows/reg2.yml index b15ff3a7..fc734c86 100644 --- a/.github/workflows/reg2.yml +++ b/.github/workflows/reg2.yml @@ -1,16 +1,19 @@ -# .github/workflows/reg.yml +name: Visual Regression Testing2 on: pull_request: types: [opened, reopened] jobs: - build: + reg-screenshot-test: runs-on: ubuntu-latest + timeout-minutes: 20 + permissions: actions: read # for downloading artifacts contents: write # for pushing screenshot-diff to companion branch pull-requests: write # for creating a comment on pull requests + steps: - uses: actions/checkout@v2 with: From 888adc20aa72897f2214a75958df208d728a3b01 Mon Sep 17 00:00:00 2001 From: takumi-saito Date: Thu, 8 Feb 2024 03:25:31 +0900 Subject: [PATCH 09/13] fix --- regconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/regconfig.json b/regconfig.json index b741e4b6..a9eb2053 100644 --- a/regconfig.json +++ b/regconfig.json @@ -9,6 +9,7 @@ "addIgnore": true }, "plugins": { + "reg-keygen-git-hash-plugin": true, "reg-notify-github-plugin": { "prComment": true, "prCommentBehavior": "default", From ab6c73d48521e0af1659bd61a22e1f6ea7f04df9 Mon Sep 17 00:00:00 2001 From: takumi-saito Date: Thu, 8 Feb 2024 03:38:57 +0900 Subject: [PATCH 10/13] fix --- .github/workflows/reg2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reg2.yml b/.github/workflows/reg2.yml index fc734c86..7072006e 100644 --- a/.github/workflows/reg2.yml +++ b/.github/workflows/reg2.yml @@ -37,7 +37,7 @@ jobs: gradle-version: wrapper - name: workaround for detached HEAD run: | - git checkout ${GITHUB_REF#refs/heads/} || git checkout -b ${GITHUB_REF#refs/heads/} && git pull + git checkout ${GITHUB_REF#refs/heads/} || git checkout -b ${GITHUB_REF#refs/heads/} && git pull origin ${GITHUB_REF#refs/heads/} - name: create the current snapshot run: | ./gradlew recordRoborazziDebug --stacktrace From ef1d3bcb382c63459deefcd58b749f08855905e8 Mon Sep 17 00:00:00 2001 From: takumi-saito Date: Thu, 8 Feb 2024 04:00:10 +0900 Subject: [PATCH 11/13] fix --- .github/workflows/reg.yml | 4 +++- .github/workflows/reg2.yml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reg.yml b/.github/workflows/reg.yml index e4a33f90..3b7e3b58 100644 --- a/.github/workflows/reg.yml +++ b/.github/workflows/reg.yml @@ -30,7 +30,9 @@ jobs: uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0 with: gradle-version: wrapper - + - name: workaround for detached HEAD + run: | + git checkout ${GITHUB_REF#refs/heads/} || git checkout -b ${GITHUB_REF#refs/heads/} && git pull origin ${GITHUB_REF#refs/heads/} - name: create the current snapshot run: | ./gradlew recordRoborazziDebug --stacktrace diff --git a/.github/workflows/reg2.yml b/.github/workflows/reg2.yml index 7072006e..7b3417a1 100644 --- a/.github/workflows/reg2.yml +++ b/.github/workflows/reg2.yml @@ -43,4 +43,4 @@ jobs: ./gradlew recordRoborazziDebug --stacktrace - name: run reg-suit run: | - npx reg-suit run \ No newline at end of file + npx reg-suit run --test \ No newline at end of file From 2dcbdad0fefaaec87d414b57f35d8881fa84c502 Mon Sep 17 00:00:00 2001 From: takumi-saito Date: Thu, 8 Feb 2024 04:53:50 +0900 Subject: [PATCH 12/13] fix --- .github/workflows/reg.yml | 6 +++++- .github/workflows/{reg2.yml => reg2.yml.bk} | 0 2 files changed, 5 insertions(+), 1 deletion(-) rename .github/workflows/{reg2.yml => reg2.yml.bk} (100%) diff --git a/.github/workflows/reg.yml b/.github/workflows/reg.yml index 3b7e3b58..8063894c 100644 --- a/.github/workflows/reg.yml +++ b/.github/workflows/reg.yml @@ -30,9 +30,13 @@ jobs: uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0 with: gradle-version: wrapper +# - name: workaround for detached HEAD +# run: | +# git checkout ${GITHUB_REF#refs/heads/} || git checkout -b ${GITHUB_REF#refs/heads/} && git pull origin ${GITHUB_REF#refs/heads/} - name: workaround for detached HEAD + if: ${{ github.event_name == 'pull_request' }} run: | - git checkout ${GITHUB_REF#refs/heads/} || git checkout -b ${GITHUB_REF#refs/heads/} && git pull origin ${GITHUB_REF#refs/heads/} + git checkout ${GITHUB_HEAD_REF#refs/heads/} || git checkout -b ${GITHUB_HEAD_REF#refs/heads/} && git pull - name: create the current snapshot run: | ./gradlew recordRoborazziDebug --stacktrace diff --git a/.github/workflows/reg2.yml b/.github/workflows/reg2.yml.bk similarity index 100% rename from .github/workflows/reg2.yml rename to .github/workflows/reg2.yml.bk From d6a7ff5f6ca5c9d38dd83719c54a69030365e968 Mon Sep 17 00:00:00 2001 From: takumi-saito Date: Thu, 8 Feb 2024 04:54:28 +0900 Subject: [PATCH 13/13] fix --- .github/workflows/reg.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reg.yml b/.github/workflows/reg.yml index 8063894c..f64b9f59 100644 --- a/.github/workflows/reg.yml +++ b/.github/workflows/reg.yml @@ -36,7 +36,7 @@ jobs: - name: workaround for detached HEAD if: ${{ github.event_name == 'pull_request' }} run: | - git checkout ${GITHUB_HEAD_REF#refs/heads/} || git checkout -b ${GITHUB_HEAD_REF#refs/heads/} && git pull + git checkout ${GITHUB_HEAD_REF#refs/heads/} || git checkout -b ${GITHUB_HEAD_REF#refs/heads/} && git pull origin ${GITHUB_REF#refs/heads/} - name: create the current snapshot run: | ./gradlew recordRoborazziDebug --stacktrace