Skip to content

feat: disable earn actions based on earn opportunity interaction flags #875

feat: disable earn actions based on earn opportunity interaction flags

feat: disable earn actions based on earn opportunity interaction flags #875

Workflow file for this run

name: PR Checks
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
permissions:
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint-changes:
runs-on: ubuntu-latest
steps:
- name: Configure git
run: |
git config --global user.name github-actions[bot]
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
- &checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- &pnpm-setup
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
- &node-setup
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- &install-dependencies
name: Install dependencies
run: pnpm install
- name: Lint Staged
run: |
pnpm lint-staged --diff="${PR_TARGET_SHA}...${PR_SOURCE_SHA}"
env:
PR_TARGET_SHA: ${{ github.event.pull_request.base.sha }}
PR_SOURCE_SHA: ${{ github.event.pull_request.head.sha }}
- name: Check for uncommitted changes after lint-staged
run: |
if ! git diff --staged --quiet --exit-code; then
echo "## 🎨 The following files missed linting:" > DIFF.txt
echo "" >> DIFF.txt
echo '```' >> DIFF.txt
git diff --stat --staged | head -n -1 >> DIFF.txt
echo '```' >> DIFF.txt
echo "" >> DIFF.txt
echo "To fix this issue, use \`git fetch && pnpm lint-staged --diff=\"origin/${SOURCE_NAME}...${BRANCH_NAME}\"\` to lint changed files." >> DIFF.txt
echo "" >> DIFF.txt
echo "🚧 Your commit hooks might be missing 🚧" >> DIFF.txt
exit 1
fi
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
SOURCE_NAME: ${{ github.base_ref || 'base-branch' }}
- name: Comment on PR in case of failure
if: failure()
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
with:
header: "Lint-staged"
path: DIFF.txt
- name: Hide the Comment in case of success
if: success()
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
with:
header: "Lint-staged"
hide: true
hide_classify: "RESOLVED"
test-unit:
runs-on: ubuntu-latest
steps:
- *checkout
- *pnpm-setup
- *node-setup
- *install-dependencies
- name: Run unit tests
run: pnpm test:unit
test-snapshots:
runs-on: ubuntu-latest
outputs:
summary: ${{ steps.results.outputs.summary }}
steps:
- *checkout
- *pnpm-setup
- *node-setup
- *install-dependencies
- name: Run tests
id: test
run: pnpm test:snapshots
continue-on-error: true
- name: Get test results
id: results
env:
TEST_OUTCOME: ${{ steps.test.outcome }}
run: |
if [ "$TEST_OUTCOME" = 'success' ]; then
echo "summary=✅ All snapshot tests passed" >> "$GITHUB_OUTPUT"
else
echo "summary=❌ Some snapshot tests failed. Check the logs for details." >> "$GITHUB_OUTPUT"
fi
post-snapshot-comment:
needs: [test-snapshots]
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
env:
SUMMARY: ${{ needs.test-snapshots.outputs.summary }}
with:
header: Snapshot Tests Summary
message: ${{ env.SUMMARY }}