Skip to content

Commit

Permalink
Revert "Merge pull request #502 from kosenda/feature/ci-use-githubact…
Browse files Browse the repository at this point in the history
…ions-and-circleci"

This reverts commit 22e1c41, reversing
changes made to 389dba3.
  • Loading branch information
kosenda committed Mar 18, 2024
1 parent da863fd commit a0a4544
Show file tree
Hide file tree
Showing 4 changed files with 358 additions and 293 deletions.
87 changes: 78 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ version: 2.1
orbs:
slack: circleci/[email protected]
gh: circleci/[email protected]
aws-cli: circleci/[email protected]
aws-s3: circleci/[email protected]

executors:
android:
Expand All @@ -21,6 +23,9 @@ commands:
steps:
- restore_cache:
key: jars-{{ checksum "build.gradle.kts" }}-{{ checksum "app/build.gradle.kts" }}
- run:
name: Download dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
Expand Down Expand Up @@ -78,6 +83,12 @@ commands:
# set github access token
echo "export GITHUB_ACCESS_TOKEN='$access_token'" >> $BASH_ENV
aws-cli-setup:
steps:
- aws-cli/setup:
aws_access_key_id: AWS_ACCESS_KEY_ID
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
region: AWS_REGION

jobs:
dependencies:
Expand Down Expand Up @@ -147,27 +158,85 @@ jobs:
executor: android
steps:
- checkout
- gh/install
- set-github-access-token
- run:
name: gh login
command: echo "$GITHUB_ACCESS_TOKEN" | gh auth login --with-token
- attach_workspace:
at: .
- run:
name: use github actions workflow
command: gh workflow run "SaveScreenshot.yml"
name: create screenshots
command: ./gradlew recordRoborazziProdDebug --stacktrace
- aws-cli-setup
- aws-s3/sync:
arguments: --delete
from: ./app/build/outputs/roborazzi
to: s3://hiraganaconverter-roborazzi/image/$CIRCLE_BRANCH

compare-screenshots:
executor: android
steps:
- checkout
- attach_workspace:
at: .
- gh/install
- set-github-access-token
- run:
name: gh login
command: echo "$GITHUB_ACCESS_TOKEN" | gh auth login --with-token
- run:
name: use github actions workflow
command: gh workflow run "CompareScreenshot.yml"
name: get base branch name
# ref: https://discuss.circleci.com/t/how-to-retrieve-a-pull-requests-base-branch-name-github/36911
command: |
# ◼ get base branch name
pr=$(echo https://api.github.com/repos/${CIRCLE_PULL_REQUEST:19} | sed "s/\/pull\//\/pulls\//")
base=$(curl -s -H "Authorization: token ${GITHUB_ACCESS_TOKEN}" $pr | jq '.base.ref')
echo "base branch name: $base"
echo "export BASE_BRANCH_NAME=${base}" >> $BASH_ENV
- aws-cli-setup
- aws-s3/copy:
arguments: --recursive
from: "s3://hiraganaconverter-roborazzi/image/$BASE_BRANCH_NAME"
to: ./app/build/outputs/roborazzi
- run:
name: compare screenshots
command: ./gradlew compareRoborazziProdDebug --stacktrace
- run:
name: move screenshots files
command: |
mkdir -p ./build/outputs/roborazzi/compareProdDebug
mv ./app/build/outputs/roborazzi ./build/outputs/roborazzi/compareProdDebug
# delete except *_compare.png
find ./build/outputs/roborazzi/compareProdDebug/roborazzi -type f | grep -v -e '.*_compare.png' | xargs rm -rf
ls ./build/outputs/roborazzi/compareProdDebug/roborazzi
- run:
name: set pr number
command: |
pr_number=$(basename $CIRCLE_PULL_REQUEST)
echo "export PR_NUMBER=${pr_number}" >> $BASH_ENV
- aws-s3/sync:
arguments: --delete
from: ./build/outputs/roborazzi/compareProdDebug/roborazzi
to: s3://hiraganaconverter-roborazzi/image/pr/$PR_NUMBER
- run:
name: create comments
command: |
cat \<< EOF > comments
|File name|Image|
|---|---|
EOF
# Find all the files ending with _compare.png
files_to_add=$(find . -type f -path "./build/outputs/roborazzi/compareProdDebug/roborazzi/*" -name "*_compare.png")
# Add compare image
for file in $files_to_add; do
compare_file_path=$(basename $file)
echo "compare file path: $compare_file_path"
compare_file_name=$(echo $compare_file_path | rev | cut -d. -f-2 | rev )
image_url="https://hiraganaconverter-roborazzi.s3.ap-northeast-1.amazonaws.com/image/pr/$PR_NUMBER/$compare_file_path"
echo "| $compare_file_name | <img src=\"$image_url\" width=\"600\"> |" >> comments
done
- run:
# ref: https://github.com/cli/cli/issues/6790
name: test comment
command: gh pr comment "$CIRCLE_PULL_REQUEST" --edit-last -F ./comments || gh pr comment "$CIRCLE_PULL_REQUEST" -F ./comments

workflows:
test:
Expand Down
199 changes: 0 additions & 199 deletions .github/workflows/CompareScreenshot.yml

This file was deleted.

7 changes: 6 additions & 1 deletion .github/workflows/SaveScreenshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

name: SaveScreenshot

on: workflow_dispatch
on:
pull_request:
types:
- closed
paths-ignore:
- README.md

jobs:
save-screenshot:
Expand Down
Loading

0 comments on commit a0a4544

Please sign in to comment.