diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b403a1eb737c..9d7efc7d4c29 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,6 +5,7 @@ on: pull_request: types: [opened, synchronize] branches-ignore: [staging, production] + paths: ['**.js', '**.ts', '**.tsx'] jobs: lint: @@ -12,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + uses: actions/checkout@v3 - name: Setup Node uses: Expensify/App/.github/actions/composite/setupNode@main @@ -22,9 +23,6 @@ jobs: env: CI: true - - name: Lint shell scripts with ShellCheck - run: npm run shellcheck - - name: Verify there's no Prettier diff run: | npm run prettier -- --loglevel silent diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 11753a383219..bae843e74709 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -2,8 +2,8 @@ name: Process new code merged to main on: push: - branches: - - main + branches: [main] + paths-ignore: [docs/**, contributingGuides/**, jest/**, tests/**, workflow_tests/**] jobs: typecheck: @@ -112,71 +112,6 @@ jobs: with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - # Check if actor is member of Expensify organization by looking for Expensify/expensify team - isExpensifyEmployee: - runs-on: ubuntu-latest - - outputs: - IS_EXPENSIFY_EMPLOYEE: ${{ fromJSON(steps.checkAuthor.outputs.IS_EXPENSIFY_EMPLOYEE) }} - - steps: - - name: Get merged pull request - id: getMergedPullRequest - uses: roryabraham/action-get-merged-pull-request@7a7a194f6ff8f3eef58c822083695a97314ebec1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Check whether the PR author is member of Expensify/expensify team - id: checkAuthor - run: | - if gh api /orgs/Expensify/teams/expensify-expensify/memberships/${{ steps.getMergedPullRequest.outputs.author }} --silent; then - echo "IS_EXPENSIFY_EMPLOYEE=true" >> "$GITHUB_OUTPUT" - else - echo "IS_EXPENSIFY_EMPLOYEE=false" >> "$GITHUB_OUTPUT" - fi - env: - GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} - - newContributorWelcomeMessage: - runs-on: ubuntu-latest - needs: isExpensifyEmployee - if: ${{ github.actor != 'OSBotify' && !fromJSON(needs.isExpensifyEmployee.outputs.IS_EXPENSIFY_EMPLOYEE) && github.actor != 'imgbot[bot]' }} - steps: - # Version: 2.3.4 - - name: Checkout - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - with: - token: ${{ secrets.OS_BOTIFY_TOKEN }} - - - name: Get merged pull request - id: getMergedPullRequest - # TODO: Point back action actions-ecosystem after https://github.com/actions-ecosystem/action-get-merged-pull-request/pull/223 is merged - uses: roryabraham/action-get-merged-pull-request@7a7a194f6ff8f3eef58c822083695a97314ebec1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Get PR count for ${{ steps.getMergedPullRequest.outputs.author }} - run: echo "PR_COUNT=$(gh pr list --author ${{ steps.getMergedPullRequest.outputs.author }} --state any | grep -c '')" >> "$GITHUB_ENV" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Comment on ${{ steps.getMergedPullRequest.outputs.author }}\'s first pull request! - if: ${{ fromJSON(env.PR_COUNT) == 1 }} - uses: actions-ecosystem/action-create-comment@cd098164398331c50e7dfdd0dfa1b564a1873fac - with: - github_token: ${{ secrets.OS_BOTIFY_TOKEN }} - number: ${{ steps.getMergedPullRequest.outputs.number }} - body: | - @${{ steps.getMergedPullRequest.outputs.author }}, Great job getting your first Expensify/App pull request over the finish line! :tada: - - I know there's a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo:: - - 1. Now that your first PR has been merged, you can be hired for another issue. Once you've completed a few issues, you may be eligible to work on more than one job at a time. - 2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn't work as expected or causes a regression, you'll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression. - 3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag: - - So it might take a while before you're paid for your work, but we typically post multiple new jobs every day, so there's plenty of opportunity. I hope you've had a positive experience contributing to this repo! :blush: - e2ePerformanceTests: needs: [chooseDeployActions] if: ${{ needs.chooseDeployActions.outputs.SHOULD_DEPLOY }} diff --git a/.github/workflows/reassurePerformanceTests.yml b/.github/workflows/reassurePerformanceTests.yml index ab5e1d06e5a4..b259ff9052b6 100644 --- a/.github/workflows/reassurePerformanceTests.yml +++ b/.github/workflows/reassurePerformanceTests.yml @@ -4,6 +4,7 @@ on: pull_request: types: [opened, synchronize] branches-ignore: [staging, production] + paths-ignore: [docs/**, .github/**, contributingGuides/**, tests/**, workflow_tests/**, '**.md', '**.sh'] jobs: perf-tests: diff --git a/.github/workflows/shellCheck.yml b/.github/workflows/shellCheck.yml new file mode 100644 index 000000000000..609541e9a660 --- /dev/null +++ b/.github/workflows/shellCheck.yml @@ -0,0 +1,19 @@ +name: Lint shell code + +on: + workflow_call: + pull_request: + types: [opened, synchronize] + branches-ignore: [staging, production] + paths: ['**.sh'] + +jobs: + lint: + if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Lint shell scripts with ShellCheck + run: npm run shellcheck diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c37f3a766f7c..fa47a2f61d4a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,7 @@ on: pull_request: types: [opened, synchronize] branches-ignore: [staging, production] + paths: ['**.js', '**.ts', '**.tsx', '**.sh', 'package.json', 'package-lock.json'] jobs: jest: diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml index de433b2ae88a..776169fc6058 100644 --- a/.github/workflows/typecheck.yml +++ b/.github/workflows/typecheck.yml @@ -5,6 +5,7 @@ on: pull_request: types: [opened, synchronize] branches-ignore: [staging, production] + paths: ['**.ts', '**.tsx', 'package.json', 'package-lock.json'] jobs: typecheck: diff --git a/.github/workflows/welcome.yml b/.github/workflows/welcome.yml new file mode 100644 index 000000000000..43e0e1650381 --- /dev/null +++ b/.github/workflows/welcome.yml @@ -0,0 +1,55 @@ +name: Post new contributor welcome message + +on: + push: + branches: [main] + +jobs: + newContributorWelcomeMessage: + runs-on: ubuntu-latest + if: ${{ github.actor != 'OSBotify' && github.actor != 'imgbot[bot]' }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Get merged pull request + id: getMergedPullRequest + run: | + read -r number author < <(gh pr list --search ${{ github.sha }} --state merged --json 'number,author' | jq -r '.[0] | [.number, .author.login] | join(" ")') + echo "number=$number" >> "$GITHUB_OUTPUT" + echo "author=$author" >> "$GITHUB_OUTPUT" + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Check whether the PR author is member of Expensify/expensify team + id: isExpensifyEmployee + run: | + if gh api /orgs/Expensify/teams/expensify-expensify/memberships/${{ steps.getMergedPullRequest.outputs.author }} --silent; then + echo "IS_EXPENSIFY_EMPLOYEE=true" >> "$GITHUB_OUTPUT" + else + echo "IS_EXPENSIFY_EMPLOYEE=false" >> "$GITHUB_OUTPUT" + fi + env: + GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} + + - name: Get PR count for ${{ steps.getMergedPullRequest.outputs.author }} + id: getPRCount + run: echo "PR_COUNT=$(gh pr list --author ${{ steps.getMergedPullRequest.outputs.author }} --state any | grep -c '')" >> "$GITHUB_OUTPUT" + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Comment on ${{ steps.getMergedPullRequest.outputs.author }}\'s first pull request! + if: ${{ fromJSON(steps.getPRCount.outputs.PR_COUNT) == 1 }} + run: | + gh pr comment ${{ steps.getMergedPullRequest.outputs.number }} --body \ + "@${{ steps.getMergedPullRequest.outputs.author }}, Great job getting your first Expensify/App pull request over the finish line! :tada: + + I know there's a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo:: + + 1. Now that your first PR has been merged, you can be hired for another issue. Once you've completed a few issues, you may be eligible to work on more than one job at a time. + 2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn't work as expected or causes a regression, you'll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression. + 3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag: + + So it might take a while before you're paid for your work, but we typically post multiple new jobs every day, so there's plenty of opportunity. I hope you've had a positive experience contributing to this repo! :blush:" + env: + GITHUB_TOKEN: ${{ github.token }} diff --git a/scripts/shellCheck.sh b/scripts/shellCheck.sh index 14424b4d9b30..d148958900d4 100755 --- a/scripts/shellCheck.sh +++ b/scripts/shellCheck.sh @@ -22,7 +22,13 @@ info ASYNC_PROCESSES=() for SHELL_SCRIPT in $SHELL_SCRIPTS; do - npx shellcheck -e SC1091 "$SHELL_SCRIPT" & + if [[ "$CI" == 'true' ]]; then + # ShellCheck is installed by default on GitHub Actions ubuntu runners + shellcheck -e SC1091 "$SHELL_SCRIPT" & + else + # Otherwise shellcheck is used via npx + npx shellcheck -e SC1091 "$SHELL_SCRIPT" & + fi ASYNC_PROCESSES+=($!) done