Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
PKG_VERSION=$(cd $GITHUB_WORKSPACE/dist/ionic-header-parallax && npm pkg get version | tr -d '"')
mkdir cypress
cp -r $GITHUB_WORKSPACE/cypress/* ./cypress
cp $GITHUB_WORKSPACE/cypress.config.ts .
cp -r $GITHUB_WORKSPACE/src/app/home/* ./src/app/home
npm i $GITHUB_WORKSPACE/dist/ionic-header-parallax-$PKG_VERSION.tgz
cypress install
ng serve --host 0.0.0.0 --port 4200 & \
(wait-on http://0.0.0.0:4200 --timeout 30000 --interval 1000 && cypress run --headless) \
|| { echo 'Angular server failed to start'; exit 1; }
37 changes: 25 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Run Tests
on: [push, pull_request]

jobs:
test:
test-angular19:
runs-on: ubuntu-latest
container:
image: raschidjfr/ionic-blank:ionic8-angular19-cypress14
Expand All @@ -12,18 +12,31 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies and build project
- name: Install dependencies
run: npm ci

- name: Build project
run: npm run build

- name: Run tests
working-directory: /app
run: bash $GITHUB_WORKSPACE/.github/workflows/run-tests.sh

test-angular16:
runs-on: ubuntu-latest
container:
image: raschidjfr/ionic-blank:ionic8-angular16-cypress14

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: npm ci

- name: Build project
run: npm run build

- name: Run tests
working-directory: /app
run: |
PKG_VERSION=$(cd $GITHUB_WORKSPACE/dist/ionic-header-parallax && npm pkg get version | tr -d '"')
mkdir cypress
cp -r $GITHUB_WORKSPACE/cypress/* ./cypress
cp $GITHUB_WORKSPACE/cypress.config.ts .
cp -r $GITHUB_WORKSPACE/src/app/home/* ./src/app/home
npm i $GITHUB_WORKSPACE/dist/ionic-header-parallax/ionic-header-parallax-$PKG_VERSION.tgz
ng serve --host 0.0.0.0 --port 4200 &
(wait-on http://0.0.0.0:4200 --timeout 30000 --interval 1000 && cypress run --headless) \
|| { echo 'Angular server failed to start'; exit 1; }
run: bash $GITHUB_WORKSPACE/.github/workflows/run-tests.sh
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In the root folder:
2. Run `ng serve` to launch the demo app.

### Test
1. Build: `npm run build -- -c production`
1. Build: `npm run build`
2. Test with Docker: `bin/test.sh`


20 changes: 12 additions & 8 deletions bin/test.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
#!/bin/bash
# Use this to test the angular project with cypress.
# Execute from the project's root folder.
# Usage: bin/test.sh [angular_version]

get_lib_version() {
echo $(cd dist/ionic-header-parallax && npm pkg get version)
}

run_test() {
version=$1
ng_version=$1
lib_version=$(get_lib_version)
docker run \
--rm \
-ti \
-v "$PWD:/project" \
-v "$PWD/dist/ionic-header-parallax:/dist" \
raschidjfr/ionic-blank:ionic8-angular19-cypress14 \
-v "$PWD/dist:/dist" \
raschidjfr/ionic-blank:ionic8-angular$ng_version-cypress14 \
bash -c "\
mkdir cypress \
&& cp -r /project/cypress/* ./cypress \
&& cp /project/cypress.config.ts . \
&& cp -r /project/src/app/home/* ./src/app/home \
&& npm i /dist/ionic-header-parallax-$version.tgz \
&& ng serve --host 0.0.0.0 --port 4200 \
&& npm i /dist/ionic-header-parallax-$lib_version.tgz \
&& (ng serve --host 0.0.0.0 --port 4200 \
& (wait-on http://0.0.0.0:4200 && cypress run --headless) \
|| { echo 'Angular server failed to start'; exit 1; }"
|| { echo 'Angular server failed to start'; exit 1; })"
}

lib_version=$(get_lib_version)
run_test $lib_version
ng_version="${1:-19}"
echo "Testing library in Ionic v8 and Angular v$ng_version..."
run_test $ng_version
Loading