diff --git a/.github/actions/composite/setupNode/action.yml b/.github/actions/composite/setupNode/action.yml new file mode 100644 index 000000000000..802a584e6e92 --- /dev/null +++ b/.github/actions/composite/setupNode/action.yml @@ -0,0 +1,20 @@ +name: Set up Node +description: Set up Node + +runs: + using: composite + steps: + # Version: 3.0.2 + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + + - uses: actions/setup-node@09ba51f18e18a3756fea1f54d09c6745c064491d + with: + node-version: 16 + cache: npm + + - name: Install node packages + uses: nick-invision/retry@7c68161adf97a48beb850a595b8784ec57a98cbb + with: + timeout_minutes: 10 + max_attempts: 5 + command: npm ci diff --git a/.github/scripts/validateActionsAndWorkflows.sh b/.github/scripts/validateActionsAndWorkflows.sh index 2d93cc97695d..9ac61c2e23a5 100755 --- a/.github/scripts/validateActionsAndWorkflows.sh +++ b/.github/scripts/validateActionsAndWorkflows.sh @@ -79,6 +79,9 @@ fi info 'Linting workflows...' ./actionlint -color || EXIT_CODE=1 +if [[ "$EXIT_CODE" == 0 ]]; then + success 'Workflows passed actionlint!' +fi # Cleanup after ourselves and delete actionlint rm -rf ./actionlint diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 05c2e2b441fb..5d308c47b1e2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,28 +11,7 @@ jobs: if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Setup Node - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - - - name: Install node packages - uses: nick-invision/retry@7c68161adf97a48beb850a595b8784ec57a98cbb - with: - timeout_minutes: 10 - max_attempts: 5 - command: npm ci + - uses: Expensify/App/.github/composite/setupNode@main - run: npm run lint env: diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 6b84cbcc95b7..369c023f5a0d 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -31,40 +31,12 @@ jobs: if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: Expensify/App/.github/actions/composite/setupNode@main - - uses: actions/setup-ruby@v1 + - uses: ruby/setup-ruby@08245253a76fa4d1e459b7809579c62bd9eb718a with: ruby-version: '2.7' - - - uses: actions/cache@v2 - with: - path: vendor/bundle - key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} - - - name: Install bundler - run: | - bundle config path vendor/bundle - gem install bundler - - - name: Install gems - run: bundle install - - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - - - name: Install node packages - uses: nick-invision/retry@7c68161adf97a48beb850a595b8784ec57a98cbb - with: - timeout_minutes: 10 - max_attempts: 5 - command: npm ci + bundler-cache: true - name: Decrypt keystore run: cd android/app && gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output my-upload-key.keystore my-upload-key.keystore.gpg @@ -117,28 +89,7 @@ jobs: if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }} runs-on: macos-11 steps: - - uses: actions/checkout@v2 - - - name: Setup Node - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - - - name: Install node packages - uses: nick-invision/retry@7c68161adf97a48beb850a595b8784ec57a98cbb - with: - timeout_minutes: 10 - max_attempts: 5 - command: npm ci + - uses: Expensify/App/.github/composite/setupNode@main - name: Decrypt Developer ID Certificate run: cd desktop && gpg --quiet --batch --yes --decrypt --passphrase="$DEVELOPER_ID_SECRET_PASSPHRASE" --output developer_id.p12 developer_id.p12.gpg @@ -173,45 +124,12 @@ jobs: if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }} runs-on: macos-11 steps: - - uses: actions/checkout@v2 - - - name: Setup Node - uses: actions/setup-node@v1 - with: - node-version: '14.x' + - uses: Expensify/App/.github/composite/setupNode@main - - uses: actions/setup-ruby@v1 + - uses: ruby/setup-ruby@08245253a76fa4d1e459b7809579c62bd9eb718a with: ruby-version: '2.7' - - - uses: actions/cache@v2 - with: - path: vendor/bundle - key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} - - - name: Install bundler - run: | - bundle config path vendor/bundle - gem install bundler - - - name: Install gems - run: bundle install - - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - - - name: Install node packages - uses: nick-invision/retry@7c68161adf97a48beb850a595b8784ec57a98cbb - with: - timeout_minutes: 10 - max_attempts: 5 - command: npm ci + bundler-cache: true - name: Install cocoapods uses: nick-invision/retry@7c68161adf97a48beb850a595b8784ec57a98cbb @@ -278,12 +196,7 @@ jobs: if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Setup Node - uses: actions/setup-node@v1 - with: - node-version: '14.x' + - uses: Expensify/App/.github/composite/setupNode@main - name: Setup python run: sudo apt-get install python3-setuptools @@ -303,22 +216,6 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-1 - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - - - name: Install node packages - uses: nick-invision/retry@7c68161adf97a48beb850a595b8784ec57a98cbb - with: - timeout_minutes: 10 - max_attempts: 5 - command: npm ci - - name: Build web for production if: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} run: npm run build @@ -427,14 +324,10 @@ jobs: if: ${{ always() }} needs: [android, desktop, iOS, web] steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 + - uses: Expensify/App/.github/actions/composite/setupNode@main - - name: Setup Node - uses: actions/setup-node@v1 - with: - node-version: '14.x' + - name: Fetch tags + run: git fetch --tags - name: Set version run: echo "VERSION=$(npm run print-version --silent)" >> "$GITHUB_ENV" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ea730c100996..fd1ecbd50e90 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: Expensify/App/.github/composite/setupNode@main # If automatic signing is enabled, iOS builds will fail, so ensure we always have the proper profile specified - name: Check Provisioning Style @@ -23,27 +23,6 @@ jobs: exit 1 fi - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - - - name: Install node packages - uses: nick-invision/retry@7c68161adf97a48beb850a595b8784ec57a98cbb - with: - timeout_minutes: 10 - max_attempts: 5 - command: npm ci - - name: Jest Unit Tests run: npm run test env: diff --git a/.github/workflows/validateGithubActions.yml b/.github/workflows/validateGithubActions.yml index 990763f30af0..0d1cf1fc65f3 100644 --- a/.github/workflows/validateGithubActions.yml +++ b/.github/workflows/validateGithubActions.yml @@ -10,28 +10,7 @@ jobs: if: github.actor != 'OSBotify' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - - - name: Install node packages - uses: nick-invision/retry@7c68161adf97a48beb850a595b8784ec57a98cbb - with: - timeout_minutes: 10 - max_attempts: 5 - command: npm ci + - uses: Expensify/App/.github/composite/setupNode@main # Rebuild all the actions on this branch and check for a diff. Fail if there is one, # because that would be a sign that the PR author did not rebuild the Github Actions diff --git a/.github/workflows/verifyPodfile.yml b/.github/workflows/verifyPodfile.yml index 242cdfe08aaf..efcfa4345d81 100644 --- a/.github/workflows/verifyPodfile.yml +++ b/.github/workflows/verifyPodfile.yml @@ -10,27 +10,6 @@ jobs: if: github.actor != 'OSBotify' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - - - name: Install node packages - uses: nick-invision/retry@7c68161adf97a48beb850a595b8784ec57a98cbb - with: - timeout_minutes: 10 - max_attempts: 5 - command: npm ci + - uses: Expensify/App/.github/composite/setupNode@main - run: ./.github/scripts/verifyPodfile.sh