Skip to content

Commit d7e5219

Browse files
test(ionic-react|ionic-angular): use local Capacitor build for e2e tests (#578)
* test(ionic-react|ionic-angular): use local Capacitor build for e2e tests * update github action
1 parent b625302 commit d7e5219

4 files changed

Lines changed: 156 additions & 150 deletions

File tree

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
jobs:
9+
main:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.event_name != 'pull_request' }}
12+
13+
env:
14+
NX_CLOUD_AUTH_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }}
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
name: Checkout [main]
19+
with:
20+
fetch-depth: 0
21+
- name: Derive appropriate SHAs for base and head for `nx affected` commands
22+
uses: nrwl/nx-set-shas@v2
23+
- uses: actions/setup-node@v1
24+
with:
25+
node-version: '16'
26+
- uses: bahmutov/npm-install@v1
27+
- run: npm -g i firebase-tools
28+
- run: npx nx format:check
29+
- run: npx nx affected --target=build --parallel --max-parallel=3
30+
- run: npx nx affected --target=lint --parallel --max-parallel=3
31+
- run: npx nx affected --target=test --parallel --max-parallel=2
32+
- run: npx nx affected --target=build --all --max-parallel=3
33+
- run: npx nx affected --target=e2e
34+
pr:
35+
runs-on: ubuntu-latest
36+
if: ${{ github.event_name == 'pull_request' }}
37+
38+
env:
39+
NX_CLOUD_AUTH_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }}
40+
41+
steps:
42+
- uses: actions/checkout@v2
43+
with:
44+
ref: ${{ github.event.pull_request.head.ref }}
45+
fetch-depth: 0
46+
- name: Derive appropriate SHAs for base and head for `nx affected` commands
47+
uses: nrwl/nx-set-shas@v2
48+
- uses: actions/setup-node@v1
49+
with:
50+
node-version: '16'
51+
- uses: bahmutov/npm-install@v1
52+
- run: npm -g i firebase-tools
53+
- run: npx nx format:check
54+
- run: npx nx affected --target=build --parallel --max-parallel=3
55+
- run: npx nx affected --target=lint --parallel --max-parallel=3
56+
- run: npx nx affected --target=test --parallel --max-parallel=2
57+
- run: npx nx affected --target=build --all --max-parallel=3
58+
- run: npx nx affected --target=e2e

.github/workflows/nx-affected.yml

Lines changed: 0 additions & 120 deletions
This file was deleted.

e2e/ionic-angular-e2e/tests/ionic-angular.spec.ts

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
import {
22
ensureNxProject,
3-
runCommandAsync,
3+
patchPackageJsonForPlugin,
44
runNxCommandAsync,
5+
runPackageManagerInstall,
56
uniq,
67
} from '@nrwl/nx-plugin/testing';
78

9+
function ensureNxProjectWithDeps(
10+
npmPackageName?: string,
11+
pluginDistPath?: string,
12+
optionalNpmPackages?: [npmPackageName: string, pluginDistPath: string][]
13+
): void {
14+
ensureNxProject(npmPackageName, pluginDistPath);
15+
optionalNpmPackages.forEach(([npmPackageName, pluginDistPath]) =>
16+
patchPackageJsonForPlugin(npmPackageName, pluginDistPath)
17+
);
18+
runPackageManagerInstall();
19+
}
20+
821
describe('Ionic Angular Application', () => {
922
const asyncTimeout = 600_000;
1023

@@ -37,8 +50,11 @@ describe('Ionic Angular Application', () => {
3750
'blank',
3851
async () => {
3952
const appName = uniq('ionic-angular');
40-
ensureNxProject('@nxtend/ionic-angular', 'dist/packages/ionic-angular');
41-
await runCommandAsync('yarn add -D @nxtend/capacitor');
53+
ensureNxProjectWithDeps(
54+
'@nxtend/ionic-angular',
55+
'dist/packages/ionic-angular',
56+
[['@nxtend/capacitor', 'dist/packages/capacitor']]
57+
);
4258
await runNxCommandAsync(
4359
`generate @nxtend/ionic-angular:app --name ${appName} --capacitor false --template blank`
4460
);
@@ -52,8 +68,11 @@ describe('Ionic Angular Application', () => {
5268
'list',
5369
async () => {
5470
const appName = uniq('ionic-angular');
55-
ensureNxProject('@nxtend/ionic-angular', 'dist/packages/ionic-angular');
56-
await runCommandAsync('yarn add -D @nxtend/capacitor');
71+
ensureNxProjectWithDeps(
72+
'@nxtend/ionic-angular',
73+
'dist/packages/ionic-angular',
74+
[['@nxtend/capacitor', 'dist/packages/capacitor']]
75+
);
5776
await runNxCommandAsync(
5877
`generate @nxtend/ionic-angular:app --name ${appName} --capacitor false --template list`
5978
);
@@ -67,8 +86,11 @@ describe('Ionic Angular Application', () => {
6786
'sidemenu',
6887
async () => {
6988
const appName = uniq('ionic-angular');
70-
ensureNxProject('@nxtend/ionic-angular', 'dist/packages/ionic-angular');
71-
await runCommandAsync('yarn add -D @nxtend/capacitor');
89+
ensureNxProjectWithDeps(
90+
'@nxtend/ionic-angular',
91+
'dist/packages/ionic-angular',
92+
[['@nxtend/capacitor', 'dist/packages/capacitor']]
93+
);
7294
await runNxCommandAsync(
7395
`generate @nxtend/ionic-angular:app --name ${appName} --capacitor false --template sidemenu`
7496
);
@@ -82,8 +104,11 @@ describe('Ionic Angular Application', () => {
82104
'tabs',
83105
async () => {
84106
const appName = uniq('ionic-angular');
85-
ensureNxProject('@nxtend/ionic-angular', 'dist/packages/ionic-angular');
86-
await runCommandAsync('yarn add -D @nxtend/capacitor');
107+
ensureNxProjectWithDeps(
108+
'@nxtend/ionic-angular',
109+
'dist/packages/ionic-angular',
110+
[['@nxtend/capacitor', 'dist/packages/capacitor']]
111+
);
87112
await runNxCommandAsync(
88113
`generate @nxtend/ionic-angular:app --name ${appName} --capacitor false --template tabs`
89114
);
@@ -98,8 +123,11 @@ describe('Ionic Angular Application', () => {
98123
'should generate application in subdir',
99124
async () => {
100125
const appName = uniq('ionic-angular');
101-
ensureNxProject('@nxtend/ionic-angular', 'dist/packages/ionic-angular');
102-
await runCommandAsync('yarn add -D @nxtend/capacitor');
126+
ensureNxProjectWithDeps(
127+
'@nxtend/ionic-angular',
128+
'dist/packages/ionic-angular',
129+
[['@nxtend/capacitor', 'dist/packages/capacitor']]
130+
);
103131
await runNxCommandAsync(
104132
`generate @nxtend/ionic-angular:app --name ${appName} --capacitor false --directory myDir`
105133
);
@@ -113,8 +141,11 @@ describe('Ionic Angular Application', () => {
113141
'should add tags',
114142
async () => {
115143
const appName = uniq('ionic-angular');
116-
ensureNxProject('@nxtend/ionic-angular', 'dist/packages/ionic-angular');
117-
await runCommandAsync('yarn add -D @nxtend/capacitor');
144+
ensureNxProjectWithDeps(
145+
'@nxtend/ionic-angular',
146+
'dist/packages/ionic-angular',
147+
[['@nxtend/capacitor', 'dist/packages/capacitor']]
148+
);
118149
await runNxCommandAsync(
119150
`generate @nxtend/ionic-angular:app --name ${appName} --capacitor false --tags one,two`
120151
);
@@ -128,8 +159,11 @@ describe('Ionic Angular Application', () => {
128159
'should create with unitTestRunner=none',
129160
async () => {
130161
const appName = uniq('ionic-angular');
131-
ensureNxProject('@nxtend/ionic-angular', 'dist/packages/ionic-angular');
132-
await runCommandAsync('yarn add -D @nxtend/capacitor');
162+
ensureNxProjectWithDeps(
163+
'@nxtend/ionic-angular',
164+
'dist/packages/ionic-angular',
165+
[['@nxtend/capacitor', 'dist/packages/capacitor']]
166+
);
133167
await runNxCommandAsync(
134168
`generate @nxtend/ionic-angular:app --name ${appName} --capacitor false --unitTestRunner none`
135169
);
@@ -143,8 +177,11 @@ describe('Ionic Angular Application', () => {
143177
'should create with unitTestRunner=karma',
144178
async () => {
145179
const appName = uniq('ionic-angular');
146-
ensureNxProject('@nxtend/ionic-angular', 'dist/packages/ionic-angular');
147-
await runCommandAsync('yarn add -D @nxtend/capacitor');
180+
ensureNxProjectWithDeps(
181+
'@nxtend/ionic-angular',
182+
'dist/packages/ionic-angular',
183+
[['@nxtend/capacitor', 'dist/packages/capacitor']]
184+
);
148185
await runNxCommandAsync(
149186
`generate @nxtend/ionic-angular:app --name ${appName} --capacitor false --unitTestRunner karma`
150187
);

0 commit comments

Comments
 (0)