-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Merge pull request #502 from kosenda/feature/ci-use-githubact…
- Loading branch information
Showing
4 changed files
with
358 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
@@ -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 | ||
|
@@ -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: | ||
|
@@ -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: | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.