Skip to content

[CI] Use Github-Actions #43

[CI] Use Github-Actions

[CI] Use Github-Actions #43

Workflow file for this run

name: Test
on:
pull_request:
branches:
- main
- develop
- feature/*
paths-ignore:
- README.md
permissions:
contents: write
actions: read
pull-requests: write
jobs:
dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
api-key: ${{ secrets.API_KEY }}
test-prod:
needs: dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
# ref: https://github.com/danger/danger/issues/913
fetch-depth: 100
- name: Setup
uses: ./.github/actions/setup
with:
api-key: ${{ secrets.API_KEY }}
- name: ktlint-check
run: ./gradlew --continue ktlintCheck
- name: Test ProdDebug
run: ./gradlew testProdDebugUnitTest
- name: Report jacoco
run: ./gradlew jacocoTestReport
- name: jacoco-report to zip
run: zip -r jacocoTestReport.zip ./build/reports/jacoco/jacocoTestReport/html
- name: Archive jacoco report
uses: actions/upload-artifact@v4
with:
name: jacocoTestReport
path: ./build/reports/jacoco/jacocoTestReport/html
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
bundler-cache: true
- name: Danger
uses: MeilCli/danger-action@v5
with:
plugins_file: Gemfile
install_path: vendor/bundle
danger_file: Dangerfile
danger_id: danger-pr
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
- name: Slack notify
uses: ./.github/actions/incoming-webhook
with:
slack-webhook-url: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }}
compile-mock:
needs: dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
api-key: ${{ secrets.API_KEY }}
- name: Compile MockDebug
run: ./gradlew compileMockDebugSource
compare-screnshots:
needs: dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
api-key: ${{ secrets.API_KEY }}
- name: compare screenshots
run: ./gradlew compareRoborazziProdDebug --stacktrace
- name: Make PR number directory for saving screenshots
if: ${{ github.event_name == 'pull_request' }}
run: mkdir -p ./pr/${{ github.event.number }}
- name: Move screenshots to PR number directory
if: ${{ github.event_name == 'pull_request' }}
run: |
# delete except *_compare.png
find ./app/build/outputs/roborazzi -type f | grep -v -e '.*_compare.png' | xargs rm -rf
mv ./app/build/outputs/roborazzi ./pr/${{ github.event.number }}/
ls ./pr/${{ github.event.number }}
- name: Save screenshots
uses: actions/upload-artifact@v4
with:
name: pr directory
path: pr/${{ github.event.number }}/
- name: Create comments
id: create-comments
run: |
delimiter="$(openssl rand -hex 8)"
{
echo "comments<<${delimiter}"
echo comments<<"$(openssl rand -hex 8)"
echo "Snapshot diff report" >> comments
echo "|File name|Image|" >> comments
echo "|---|---|" >> comments
# Find all the files ending with _compare.png
files_to_add=$(find . -type f -path "./pr/${{ github.event.number }}/*" -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 )
echo echo 'Artifact URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}'
image_url="${{ steps.artifact-upload-step.outputs.artifact-url }}'/roborazzi/pr/$PR_NUMBER/$compare_file_path"
echo "| $compare_file_name | <img src=\"$image_url\" width=\"600\"> |" >> comments
done
echo "${delimiter}" >> comments
} >> "$GITHUB_OUTPUT"
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.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@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.number }}
body: ${{ steps.create-comments.outputs.comments }}
edit-mode: replace