Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
fix: resolve remaining CI issues (#4798)
Browse files Browse the repository at this point in the history
* fix(webpack-config): add missing `@types/babel__code-frame`

* fix(xdl): remove typescript references and use dependencies instead

* fix(xdl): add missing `@types/lodash`

* fix(expo-cli): add missing `node-fetch` and `@types/node-fetch`

* fix(expo-cli): add `@ts-expect-error` for `@expo/package-manager` spinner option

* chore: update lockfile

* refactor(expo-cli): make spawn failures in `eject-test.ts` visible

* refactor(expo-cli): add `npm install` fallback to `yarn install`

* chore: disable caching `node_modules` in test workflow

* refactor: simplify the ci build pipeline and avoid caching node modules

* refactor: finalize new working workflows
  • Loading branch information
byCedric authored Dec 22, 2023
1 parent 361f901 commit 0a11ffa
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 116 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ on:
types: [opened, synchronize]

jobs:
build:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['16']
name: Build with Node ${{ matrix.node }}
name: Lint with Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -21,15 +21,9 @@ jobs:
with:
node-version: ${{ matrix.node }}
- run: yarn install --frozen-lockfile --check-files
- run: yarn lerna run prepare --stream
- run: yarn lint --max-warnings=0
- uses: actions/cache@v2
with:
path: '*'
key: v2-${{ github.sha }}-${{ matrix.node }}
test:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
Expand All @@ -46,16 +40,20 @@ jobs:
]
name: Test ${{ matrix.package }} on Node ${{ matrix.node }}
steps:
- uses: actions/cache@v2
- uses: actions/checkout@v3
with:
path: '*'
key: v2-${{ github.sha }}-${{ matrix.node }}
fetch-depth: 1
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install packages
run: yarn install --frozen-lockfile --check-files
- name: Build packages
run: yarn lerna run prepare --stream
- name: Test ${{ matrix.package }}
run: cd packages/${{ matrix.package }} && yarn test
working-directory: packages/${{ matrix.package }}
run: yarn test
# run: cd packages/${{ matrix.package }} && yarn test --coverage
env:
CI: true
Expand Down
20 changes: 9 additions & 11 deletions .github/workflows/test_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:
types: [opened, synchronize]
jobs:
build:
lint:
runs-on: windows-latest
strategy:
matrix:
Expand All @@ -20,15 +20,9 @@ jobs:
with:
node-version: ${{ matrix.node }}
- run: yarn install --frozen-lockfile --network-timeout 120000
- run: yarn lerna run prepare --stream
- run: yarn lint --max-warnings=0
- uses: actions/cache@v2
with:
path: '*'
key: v2-${{ github.sha }}-${{ matrix.node }}
test:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
Expand All @@ -45,16 +39,20 @@ jobs:
]
name: Test ${{ matrix.package }} on Node ${{ matrix.node }}
steps:
- uses: actions/cache@v2
- uses: actions/checkout@v3
with:
path: '*'
key: v2-${{ github.sha }}-${{ matrix.node }}
fetch-depth: 1
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install packages
run: yarn install --frozen-lockfile --check-files
- name: Build packages
run: yarn lerna run prepare --stream
- name: Test ${{ matrix.package }}
run: cd packages/${{ matrix.package }} && yarn test
working-directory: packages/${{ matrix.package }}
run: yarn test
# run: cd packages/${{ matrix.package }} && yarn test --coverage
env:
CI: true
Expand Down
28 changes: 22 additions & 6 deletions packages/expo-cli/e2e/TestUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ExpoConfig } from '@expo/config';
import JsonFile from '@expo/json-file';
import spawnAsync, { SpawnOptions, SpawnResult } from '@expo/spawn-async';
import spawnAsync, { SpawnOptions, SpawnPromise, SpawnResult } from '@expo/spawn-async';
import fs from 'fs';
import path from 'path';

Expand All @@ -14,8 +14,14 @@ function isSpawnResult(errorOrResult: Error): errorOrResult is Error & SpawnResu

export async function runAsync(args: string[], options?: SpawnOptions): Promise<SpawnResult> {
const promise = spawnAsync(EXPO_CLI, args, options);
promise.child.stdout.pipe(process.stdout);
promise.child.stderr.pipe(process.stderr);

promise.child.stdout?.pipe(process.stdout);
promise.child.stderr?.pipe(process.stderr);

return await handleSpawnResult(promise);
}

export async function handleSpawnResult(promise: SpawnPromise<SpawnResult>): Promise<SpawnResult> {
try {
return await promise;
} catch (error: any) {
Expand Down Expand Up @@ -88,9 +94,19 @@ export async function createMinimalProjectAsync(

fs.writeFileSync(path.join(projectRoot, 'App.js'), getBasicAppJs());

// TODO(Bacon): We shouldn't need this
// Install the packages so eject can infer the versions
await spawnAsync('yarn', [], { cwd: projectRoot, stdio: ['ignore', 'inherit', 'inherit'] });
try {
// TODO(Bacon): We shouldn't need this
// Install the packages so eject can infer the versions
await spawnAsync('yarn', [], {
cwd: projectRoot,
stdio: process.env.CI === 'true' ? 'inherit' : ['ignore', 'inherit', 'inherit'],
});
} catch {
await spawnAsync('npm', ['install'], {
cwd: projectRoot,
stdio: process.env.CI === 'true' ? 'inherit' : ['ignore', 'inherit', 'inherit'],
});
}

return projectRoot;
}
19 changes: 10 additions & 9 deletions packages/expo-cli/e2e/__tests__/eject-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
EXPO_CLI,
getBasicExpoConfig,
getBasicPackageJson,
handleSpawnResult,
} from '../TestUtils';

const tempDir = temporary.directory();
Expand All @@ -32,16 +33,16 @@ beforeAll(async () => {

function executeDefaultAsync(cwd: string, args: string[]) {
const promise = spawnAsync(EXPO_CLI, args, { cwd });
promise.child.stdout.pipe(process.stdout);
promise.child.stderr.pipe(process.stderr);
promise.child.stdout?.pipe(process.stdout);
promise.child.stderr?.pipe(process.stderr);

// When the test is prompted to use git, skip message
// TODO(Bacon): this shouldn't be blocking in non-interactive
promise.child.stdout.on('data', data => {
promise.child.stdout?.on('data', data => {
const stdout = data.toString();
// Skip dirty git
if (/Would you like to proceed/.test(stdout)) {
promise.child.stdin.write('\n');
promise.child.stdin?.write('\n');
}
});

Expand All @@ -59,7 +60,7 @@ it(`can eject a minimal project`, async () => {
const res = executeDefaultAsync(projectRoot, ['eject']);

// This shouldn't fail
await res;
await handleSpawnResult(res);

// Test that native folders were generated
expect(fileExists(projectName, 'ios/hworld.xcodeproj')).toBe(true);
Expand All @@ -74,11 +75,11 @@ it(`can eject a minimal project`, async () => {
// Remove main
expect(outputPkgJson.main).toBe(undefined);
// Scripts should be rewritten to use react-native-community/cli
expect(outputPkgJson.scripts['ios']).toBe('expo run:ios');
expect(outputPkgJson.scripts['android']).toBe('expo run:android');
expect(outputPkgJson.scripts['web']).toBe('expo start --web');
expect(outputPkgJson.scripts?.['ios']).toBe('expo run:ios');
expect(outputPkgJson.scripts?.['android']).toBe('expo run:android');
expect(outputPkgJson.scripts?.['web']).toBe('expo start --web');
// Ensure the react-native version doesn't change
expect(outputPkgJson.dependencies['react-native']).toBe(
expect(outputPkgJson.dependencies?.['react-native']).toBe(
getBasicPackageJson().dependencies['react-native']
);
});
Expand Down
2 changes: 2 additions & 0 deletions packages/expo-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@types/js-yaml": "^3.12.2",
"@types/klaw-sync": "^6.0.0",
"@types/minipass": "^3.1.2",
"@types/node-fetch": "^2.6.9",
"@types/npm-package-arg": "^6.1.0",
"@types/pngjs": "^3.4.1",
"@types/progress": "^2.0.3",
Expand Down Expand Up @@ -100,6 +101,7 @@
"leven": "^3.1.0",
"lodash": "^4.17.19",
"minipass": "3.1.6",
"node-fetch": "^2.7.0",
"npm-package-arg": "6.1.0",
"ora": "3.4.0",
"pngjs": "3.4.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/expo-cli/src/commands/utils/CreateApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ export async function installCocoaPodsAsync(projectRoot: string) {
}

try {
await packageManager.installAsync({ spinner: step });
await packageManager.installAsync({
// @ts-expect-error Multiple versions of `@expo/package-manager` are installed in this repository
spinner: step,
});
// Create cached list for later
await hasPackageJsonDependencyListChangedAsync(projectRoot).catch(() => null);
step.succeed('Installed pods and initialized Xcode workspace.');
Expand Down
1 change: 1 addition & 0 deletions packages/webpack-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"expo": "^49.0.7"
},
"devDependencies": {
"@types/babel__code-frame": "^7.0.6",
"@types/copy-webpack-plugin": "^10.1.0",
"@types/css-minimizer-webpack-plugin": "3.2.1",
"@types/html-webpack-plugin": "^3.2.6",
Expand Down
2 changes: 2 additions & 0 deletions packages/xdl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@expo/config-plugins": "4.1.5",
"@expo/dev-server": "0.2.0",
"@expo/devcert": "^1.0.0",
"@expo/image-utils": "0.3.23",
"@expo/json-file": "8.2.37",
"@expo/osascript": "2.0.33",
"@expo/package-manager": "0.0.56",
Expand Down Expand Up @@ -105,6 +106,7 @@
"@types/fs-extra": "^9.0.1",
"@types/getenv": "^0.7.0",
"@types/hashids": "^1.0.30",
"@types/lodash": "^4.14.202",
"@types/node-forge": "^0.9.7",
"@types/semver": "^6.0.0",
"@types/source-map-support": "^0.5.0",
Expand Down
18 changes: 2 additions & 16 deletions packages/xdl/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,5 @@
"compilerOptions": {
"outDir": "build",
"rootDir": "src"
},
"references": [
{
"path": "../image-utils"
},
{
"path": "../json-file"
},
{
"path": "../osascript"
},
{
"path": "../plist"
}
]
}
}
}
Loading

0 comments on commit 0a11ffa

Please sign in to comment.