Skip to content

Commit

Permalink
add the gh actions setup file
Browse files Browse the repository at this point in the history
  • Loading branch information
vzaidman committed Aug 2, 2024
1 parent e3aaa0b commit f355a25
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/actions/yarn-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Install Dependencies
inputs:
use-min-supported-version:
required: false
default: false

runs:
using: "composite"
steps:
- uses: actions/setup-node@main
with:
# if both node-version-file and node-version are provided, node-version is used
node-version-file: 'package.json'
node-version: ${{ inputs.use-min-supported-version && false || 'lts/*' }}
cache: yarn
cache-dependency-path: yarn.lock
- name: Install Dependencies
run: yarn install --frozen-lockfile --non-interactive --ignore-scripts
shell: bash
33 changes: 33 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: facebook/metro/build-and-deploy
on:
push:

defaults:
run:
shell: bash

jobs:
build-and-test:
uses: ./.github/workflows/build-and-test.yml

publish-to-npm:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: ./.github/actions/yarn-install
with:
use-min-supported-version: true
- name: Check Tag Format
id: check_tag
run: |
if [[ $GITHUB_REF =~ ^refs/tags/v\d+(\.\d+){2}(-.*)?$ ]]; then
echo "valid=true" >> $GITHUB_OUTPUT
else
echo "valid=false" >> $GITHUB_OUTPUT
fi
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
- name: Infer dist-tag and run npm run publish
if: steps.check_tag.outputs.valid == 'true'
run: "./.circleci/scripts/publish.sh"
- run: rm ~/.npmrc
52 changes: 52 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: facebook/metro/build-and-test
on:
push:

defaults:
run:
shell: bash

jobs:
run-js-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- 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
steps:
- uses: actions/checkout@main
- uses: ./.github/actions/yarn-install
- run: yarn test-coverage
- name: Download Codecov Uploader
run: "./.circleci/scripts/install_codecov.sh"
- name: Upload coverage results
run: "./codecov -t ${{ secrets.CODECOV_TOKEN }} -f ./coverage/coverage-final.json"

test:
runs-on: ubuntu-latest
strategy:
matrix:
use-min-supported-version: [true, false]
steps:
- uses: actions/checkout@main
- uses: ./.github/actions/yarn-install
with:
use-min-supported-version: ${{ matrix.use-min-supported-version }}
- name: Run Jest tests
run: yarn jest --ci --maxWorkers 4 --reporters=default --reporters=jest-junit

test-windows:
if: startsWith(github.ref, 'refs/heads/windows/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: ./.github/actions/yarn-install
- name: Run Jest tests
run: yarn jest --ci --maxWorkers 4 --reporters=default --reporters=jest-junit
# todo: how max workers are best?
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,8 @@
"dependencies": {},
"engines": {
"node": ">=18"
},
"volta": {
"node": "18.0.0"
}
}

0 comments on commit f355a25

Please sign in to comment.