Skip to content

Commit

Permalink
Create a Job to generate snapshots (#276)
Browse files Browse the repository at this point in the history
* Add GH Action to create paparazzi golden images on a MacOS machine

* Upload generated golden images to the GH Action

* Add script to commit and push golden image changes to the branch

* Fix paths in the GH Action

* Make `commit-and-push` script executable

* Paparazzi Golden Images

* Change runner to `ubuntu-latest`

* Paparazzi Golden Images

* Use GitHub push action

* Enable LFS in GH Action CI

---------

Co-authored-by: GitHub Actions Bot <[email protected]>
  • Loading branch information
msasikanth and dhis2-android authored Jul 17, 2024
1 parent 16f5cd0 commit 573b2c0
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/generate-paparazzi-golden-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Generate Paparazzi Golden Images

env:
# The name of the main module repository
main_project_module: designsystem

on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
ci_job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: 'true'
fetch-depth: 0
persist-credentials: false

- name: Set Up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
cache: 'gradle'

- name: Change wrapper permissions
run: chmod +x ./gradlew

- name: Generate Golden Images
run: ./gradlew designsystem:recordPaparazziDebug

- uses: actions/upload-artifact@v4
with:
name: GoldenImages
path: ./designsystem/src/test/snapshots/
if-no-files-found: 'error'

- name: Commit Changes
run: .github/workflows/scripts/commit-changes.sh

- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
2 changes: 2 additions & 0 deletions .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: 'true'

- name: Set Up JDK
uses: actions/setup-java@v3
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/scripts/commit-changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
readonly GIT_HAS_CHANGES=1 # 0 = clean, 1 = dirty

git config user.name "GitHub Actions Bot"
git config user.email "<[email protected]>"

# Following git command checks the git diff of staged files
# and assigns the exit code to GIT_DIFF_STATUS variable.
git diff --quiet; GIT_DIFF_STATUS=$?

# If the GIT_DIFF_STATUS is 1 (GIT_HAS_CHANGES) then we know
# there are changes and we can commit the changes and push
# them to new branch
if [[ ${GIT_DIFF_STATUS} -eq ${GIT_HAS_CHANGES} ]]; then
git add -A
git commit -m "Paparazzi Golden Images"

exit 0
fi
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 573b2c0

Please sign in to comment.