Skip to content

ci: convert remaining Azure Pipelines PR checks to Github Actions #276

ci: convert remaining Azure Pipelines PR checks to Github Actions

ci: convert remaining Azure Pipelines PR checks to Github Actions #276

Workflow file for this run

name: PR
on:
pull_request:
types: [opened, synchronize, edited]
branches: [ "main", "*-stable", "release/*" ]
concurrency:
# Ensure single build of a pull request. `main` should not be affected.
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
lint-title:
name: "Lint PR title"
permissions: {}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
filter: blob:none
fetch-depth: 0
- name: Setup toolchain
uses: ./.github/actions/microsoft-setup-toolchain
with:
node-version: '22'
# We lint the PR title instead of the commit message to avoid script injection attacks.
# Using environment variables prevents potential security vulnerabilities as described in:
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#example-of-a-script-injection-attack
- name: Lint PR title
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
echo "$PR_TITLE" | npx @rnx-kit/commitlint-lite@2.0.0
build-website:
name: "Build the website"
permissions: {}
if: github.base_ref == 'main'
uses: ./.github/workflows/microsoft-build-website.yml
npm-publish-dry-run:
name: "NPM Publish (Dry Run)"
permissions: {}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
filter: blob:none
fetch-depth: 0
- name: Setup toolchain
uses: ./.github/actions/microsoft-setup-toolchain
with:
node-version: '22'
- name: Read publish tag from nx.json
id: config
run: |
PUBLISH_TAG=$(jq -r '.release.version.generatorOptions.currentVersionResolverMetadata.tag' nx.json)
echo "publishTag=${PUBLISH_TAG}" >> "$GITHUB_OUTPUT"
echo "Using publish tag from nx.json: ${PUBLISH_TAG}"
- name: Configure git
run: |
git config --global user.email "53619745+rnbot@users.noreply.github.com"
git config --global user.name "React-Native Bot"
git remote set-url origin https://rnbot:${{ secrets.GITHUB_TOKEN }}@github.com/microsoft/react-native-macos
- name: Install dependencies
run: yarn
- name: Verify release config
run: |
node .ado/scripts/prepublish-check.mjs --verbose --skip-auth --tag ${{ steps.config.outputs.publishTag }}
- name: Version and publish packages (dry run)
run: |
echo "Target branch: ${{ github.base_ref }}"
yarn nx release --dry-run --verbose
yarn-constraints:
name: "Check Yarn Constraints"
permissions: {}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
filter: blob:none
fetch-depth: 0
- name: Setup toolchain
uses: ./.github/actions/microsoft-setup-toolchain
with:
node-version: '22'
- name: Install dependencies
run: yarn
- name: Check constraints
run: yarn constraints
javascript-tests:
name: "JavaScript Tests"
permissions: {}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
filter: blob:none
fetch-depth: 0
- name: Setup toolchain
uses: ./.github/actions/microsoft-setup-toolchain
with:
node-version: '23'
- name: Install npm dependencies
run: yarn install
- name: Run Jest tests
run: yarn test-ci
- name: Run Flow type checker
run: yarn flow-check
- name: Run ESLint
run: yarn lint
- name: Run Prettier format check
run: yarn format-check
build-test-rntester:
name: "Build RNTester - ${{ matrix.platform }}, ${{ matrix.arch }}, ${{ matrix.engine }}"
permissions: {}
runs-on: macos-15
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
platform: [macos, ios, xros]
arch: [oldarch, newarch]
engine: [jsc, hermes]
include:
# Platform-specific properties
- platform: macos
sdk: macosx
scheme: RNTester-macOS
packager_platform: macos
- platform: ios
sdk: iphonesimulator
scheme: RNTester
packager_platform: ios
- platform: xros
sdk: xrsimulator
scheme: RNTester-visionOS
packager_platform: ios
# Architecture-specific properties
- arch: oldarch
new_arch_enabled: '0'
- arch: newarch
new_arch_enabled: '1'
- engine: jsc
use_hermes: '0'
- engine: hermes
use_hermes: '1'
steps:
- uses: actions/checkout@v4
with:
filter: blob:none
fetch-depth: 0
- name: Setup toolchain
uses: ./.github/actions/microsoft-setup-toolchain
with:
node-version: '23'
platform: ${{ matrix.platform }}
- name: Install npm dependencies
run: yarn install
- name: Install Pods
working-directory: packages/rn-tester
env:
RCT_NEW_ARCH_ENABLED: ${{ matrix.new_arch_enabled }}
USE_HERMES: ${{ matrix.use_hermes }}
run: |
set -eox pipefail
bundle install
bundle exec pod install --verbose
- name: Build ${{ matrix.scheme }}
env:
CCACHE_DISABLE: 1
run: |
set -eox pipefail
.ado/scripts/xcodebuild.sh packages/rn-tester/RNTesterPods.xcworkspace ${{ matrix.sdk }} Debug ${{ matrix.scheme }} build
# Integration tests - currently disabled due to Verdaccio server hanging issues
# https://github.com/microsoft/react-native-macos/issues/2344
# test-react-native-macos-init:
# name: "Test react-native-macos init"
# permissions: {}
# runs-on: macos-15
# timeout-minutes: 60
# steps:
# - uses: actions/checkout@v4
# with:
# filter: blob:none
# fetch-depth: 0
# lfs: false
# clean: true
#
# - name: Setup toolchain
# uses: ./.github/actions/microsoft-setup-toolchain
# with:
# node-version: '23'
# platform: 'macos'
#
# - name: Install npm dependencies
# run: yarn install
#
# - name: Build community CLI plugin
# run: yarn build
#
# - name: Build react-native-macos-init
# working-directory: packages/react-native-macos-init
# run: yarn build
#
# - name: Start Verdaccio server
# run: |
# npx verdaccio --config .ado/verdaccio/config.yaml &
# sleep 5
#
# - name: Configure npm for Verdaccio
# run: .ado/scripts/verdaccio.sh init
#
# - name: Publish to Verdaccio
# run: .ado/scripts/verdaccio.sh publish --branch origin/${{ github.base_ref }}
#
# - name: Export versions
# run: node .ado/scripts/export-versions.mjs
#
# - name: Initialize new project
# run: |
# set -eox pipefail
# npx --yes @react-native-community/cli init testcli --version $(cat .react_native_version) --skip-install
# working-directory: ${{ runner.temp }}
#
# - name: Install dependencies in new project
# working-directory: ${{ runner.temp }}/testcli
# run: |
# set -eox pipefail
# yarn install --mode=update-lockfile
# yarn install
#
# - name: Apply macOS template
# working-directory: ${{ runner.temp }}/testcli
# run: |
# set -eox pipefail
# ${{ github.workspace }}/.ado/scripts/verdaccio.sh configure
# node ${{ github.workspace }}/packages/react-native-macos-init/bin.js --verbose --version latest --overwrite --prerelease
# pod install --project-directory=macos
#
# - name: Build macOS app
# working-directory: ${{ runner.temp }}/testcli
# run: |
# set -eox pipefail
# npx react-native build-macos
# react-native-test-app-integration:
# name: "Test react-native-test-app integration"
# permissions: {}
# runs-on: macos-15
# timeout-minutes: 60
# steps:
# - uses: actions/checkout@v4
# with:
# filter: blob:none
# fetch-depth: 0
# clean: true
#
# - name: Setup toolchain
# uses: ./.github/actions/microsoft-setup-toolchain
# with:
# node-version: '23'
# platform: 'macos'
#
# - name: Install npm dependencies
# run: yarn install
#
# - name: Build community CLI plugin
# run: yarn build
#
# - name: Build react-native-macos-init
# working-directory: packages/react-native-macos-init
# run: yarn build
#
# - name: Start Verdaccio server
# run: |
# npx verdaccio --config .ado/verdaccio/config.yaml &
# sleep 5
#
# - name: Configure npm for Verdaccio
# run: .ado/scripts/verdaccio.sh init
#
# - name: Publish to Verdaccio
# run: .ado/scripts/verdaccio.sh publish --branch origin/${{ github.base_ref }}
#
# - name: Clone react-native-test-app
# run: |
# git clone --filter=blob:none --progress https://github.com/microsoft/react-native-test-app.git
#
# - name: Export versions
# run: node .ado/scripts/export-versions.mjs
#
# - name: Configure react-native-test-app dependencies
# working-directory: react-native-test-app
# run: |
# npm run set-react-version $(cat ${{ github.workspace }}/.react_native_version) -- --overrides '{ "react-native-macos": "1000.0.0" }'
#
# - name: Install dependencies in test app
# working-directory: react-native-test-app
# run: |
# set -eo pipefail
# ${{ github.workspace }}/.ado/scripts/verdaccio.sh configure
# yarn --no-immutable
#
# - name: Bundle JavaScript
# working-directory: react-native-test-app/example
# run: |
# yarn build:macos || yarn build:macos
#
# - name: Install Pods
# working-directory: react-native-test-app/example
# run: |
# rm -f macos/Podfile.lock
# pod install --project-directory=macos
#
# - name: Build test app
# working-directory: react-native-test-app/example
# run: |
# ../scripts/build/xcodebuild.sh macos/Example.xcworkspace build