-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add gh actions for building and testing the repo
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Install Dependencies | ||
inputs: | ||
node-version-type: | ||
required: false | ||
default: 'lts' | ||
type: choice | ||
options: | ||
- 'lts' | ||
- 'min-supported' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-node@v4 | ||
with: | ||
# If node-version is set when `inputs.node-version-type == 'lts'` then it overrides node-version-file and we use node version `lts/*` | ||
# Otherwise, only node-version-file has a value and the minimum supported version is used (set in package.json under "volta"). | ||
# | ||
# This allows us to test builds both on the minimum supported version and LTS version of node. | ||
# - Testing on minimum supported version enables us to ensure it is indeed supported. If it fails- | ||
# we can either decide to advance the minimum supported version or fix the code to support it. | ||
# - Testing on LTS could give us an early indication that the latest LTS is not supported and | ||
# allow us to decide to either fix it or limit the scope of supported versions | ||
node-version-file: 'package.json' | ||
node-version: ${{ inputs.node-version-type == 'lts' && 'lts/*' || '' }} | ||
# ensures we run tests with latest LTS when LTS is selected. | ||
check-latest: true | ||
cache: yarn | ||
cache-dependency-path: yarn.lock | ||
- name: Install Dependencies | ||
run: yarn install --frozen-lockfile --non-interactive --ignore-scripts | ||
shell: bash |
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
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: facebook/metro/build-and-test | ||
on: | ||
workflow_call: | ||
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: "Typescript, 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: "Test Coverage Calculation" | ||
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'] # 'windows-latest' | ||
node-version-type: ['lts', 'min-supported'] | ||
name: "Tests [${{ matrix.runs-on }} machine, ${{ matrix.node-version-type }} Node.js]" | ||
runs-on: ${{ matrix.runs-on }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/yarn-install | ||
with: | ||
node-version-type: ${{ matrix.node-version-type }} | ||
- name: Run Jest Tests | ||
run: yarn jest --ci --maxWorkers 4 --reporters=default --reporters=jest-junit --rootdir='./' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,5 +94,8 @@ | |
"dependencies": {}, | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
"volta": { | ||
"node": "18.0.0" | ||
} | ||
} |