diff --git a/.github/actions/yarn-install/action.yml b/.github/actions/yarn-install/action.yml new file mode 100644 index 0000000000..3bdc0e083d --- /dev/null +++ b/.github/actions/yarn-install/action.yml @@ -0,0 +1,15 @@ +name: Install Dependencies +inputs: + node-version: + required: true +runs: + using: "composite" + steps: + - uses: actions/setup-node@main + with: + node-version: ${{ inputs.node-version }} + cache: yarn + cache-dependency-path: yarn.lock + - name: Install Dependencies + run: yarn install --frozen-lockfile --non-interactive --ignore-scripts + shell: bash diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml new file mode 100644 index 0000000000..5cca584ed5 --- /dev/null +++ b/.github/workflows/build-and-deploy.yml @@ -0,0 +1,95 @@ +name: facebook/metro/build-and-deploy +on: + push: + +env: + node-version-min: v18.0.0 + node-version-lts: lts + +defaults: + run: + shell: bash + +jobs: + run-js-checks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - uses: ./.github/actions/yarn-install + with: + node-version: ${{ env.node-version-lts }} + - 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 + with: + node-version: ${{ env.node-version-lts }} + - 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" + + prepare-test: + runs-on: ubuntu-latest + outputs: + node-version-min: ${{ env.node-version-min }} + node-version-lts: ${{ env.node-version-lts }} + steps: + - run: echo "This is needed to allow 'matrix' to use these vars" + + test: + runs-on: ubuntu-latest + needs: prepare-test + strategy: + matrix: + node-version: [ + "${{ needs.prepare-test.outputs.node-version-lts }}", + "${{ needs.prepare-test.outputs.node-version-min }}" + ] + steps: + - uses: actions/checkout@main + - 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 + + test-windows: + if: startsWith(github.ref, 'refs/heads/windows/') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - uses: ./.github/actions/yarn-install + with: + node-version: ${{ env.node-version-lts }} + - name: Run Jest tests + run: yarn jest --ci --maxWorkers 4 --reporters=default --reporters=jest-junit + + # publish-to-npm: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4.1.0 + # - uses: actions/setup-node@v4 + # with: + # node-version: 18.12 + # cache: yarn + # - 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