Skip to content

Commit

Permalink
add gh actions for building and testing the repo
Browse files Browse the repository at this point in the history
  • Loading branch information
vzaidman committed Aug 8, 2024
1 parent e1ec4c7 commit 3c91124
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/actions/yarn-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Install Dependencies
inputs:
node-version:
required: false
default: '20.x'

runs:
using: "composite"
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: yarn
cache-dependency-path: yarn.lock
check-latest: true
- name: Install Dependencies
run: yarn install --frozen-lockfile --non-interactive --ignore-scripts
shell: bash
16 changes: 16 additions & 0 deletions .github/scripts/install_codecov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

# Install Codecov Uploader
# See https://docs.codecov.com/docs/codecov-uploader#using-the-uploader-with-codecovio-cloud

CODECOV_URL="https://uploader.codecov.io"

curl "${CODECOV_URL}/verification.gpg" | gpg --no-default-keyring --keyring trustedkeys.gpg --import
curl -Os "${CODECOV_URL}/latest/linux/codecov"
curl -Os "${CODECOV_URL}/latest/linux/codecov.SHA256SUM"
curl -Os "${CODECOV_URL}/latest/linux/codecov.SHA256SUM.sig"

gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM

chmod +x codecov
51 changes: 51 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: facebook/metro/build-and-test
on:
pull_request:
types: [opened, synchronize]

# head_ref is per PR, so this ensures that updating the latest PR commit
# will cancel the previous run of the workflow and trigger a new one
concurrency:
group: "build-and-test-${{ github.head_ref }}"
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
run-js-checks:
runs-on: ubuntu-latest
name: "Type check, lint, smoke test"
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/yarn-install
- run: yarn typecheck
- run: yarn typecheck-ts
- run: yarn lint
- run: yarn test-smoke

test-with-coverage:
runs-on: ubuntu-latest
name: "Tests with coverage"
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/yarn-install
- run: yarn test-coverage
- run: "./.github/scripts/install_codecov.sh"
- run: "./codecov -t ${{ secrets.CODECOV_TOKEN }} -f ./coverage/coverage-final.json"

test:
strategy:
matrix:
runs-on: ['ubuntu-latest']
node-version: ['18.0', '18.x', '20.x']
name: "Tests [Node.js ${{ matrix.node-version }}, ${{ matrix.runs-on }}]"
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/yarn-install
with:
node-version: ${{ matrix.node-version }}
- name: Run Jest Tests
run: yarn jest --ci --maxWorkers 4 --reporters=default --reporters=jest-junit --rootdir='./'

0 comments on commit 3c91124

Please sign in to comment.