Add snapshot test in OmicsPlayground #90
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
name: Snapshot test | |
on: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
unittest: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Print ls recursive | |
run: ls -R | |
- | |
name: Checkout | |
uses: actions/checkout@v3 | |
- | |
name: Print ls recursive after checkout | |
run: ls -R | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- | |
name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} | |
- | |
name: Shinytest docker | |
id: test-snapshot | |
run: | | |
docker build -t ${{ env.DOCKER_TAG }} -f ./.github/workflows/build-test-push/Dockerfile . | |
docker run --name run_tests bigomics/omicsplayground:latest | |
docker cp run_tests:omicsplayground/tests . | |
- | |
name: Upload snapshots as artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: testthat-snapshots | |
path: ./tests/* | |
if-no-files-found: ignore | |
- | |
name: Configure Git | |
run: | | |
git config --local user.name "$GITHUB_ACTOR" | |
git config --local user.email "[email protected]" | |
- | |
name: Commit and push snapshots | |
if: always() | |
run: | | |
cd ${{ github.workspace }} | |
if [[ `git status --porcelain` ]]; then | |
git checkout -b "${GITHUB_HEAD_REF}" | |
git pull -ff --rebase origin "${GITHUB_HEAD_REF}" | |
git add ./tests/* | |
git commit -m "Snapshot test failed: use snapshot_review('snapshot/') (GHA)" | |
git push --force-with-lease origin "${GITHUB_HEAD_REF}" | |
echo "snapshots pushed to repo" | |
fi | |
- | |
name: Fail GHA if snapshot test failed | |
run: | | |
if [[ "${{ steps.test.outputs.test_result }}" == "FALSE" ]]; then | |
exit 1 | |
fi |