Skip to content

Commit f085963

Browse files
authored
Feature/ci setup GitHub actions (#53)
* chore(demo): add `to-px` as devDependency * test: update test file structure and scripts * ci(actions): set up * ci(actions): fix yaml * ci(actions): fix path to workspace inside container * ci(actions): remove `\"`from version en var to fix CI error
1 parent 95de372 commit f085963

File tree

15 files changed

+1614
-143
lines changed

15 files changed

+1614
-143
lines changed

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Run Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
container:
9+
image: raschidjfr/ionic-blank:ionic8-angular19-cypress14
10+
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Install dependencies and build project
16+
run: npm ci
17+
18+
- name: Run tests
19+
working-directory: /app
20+
run: |
21+
PKG_VERSION=$(cd $GITHUB_WORKSPACE/dist/ionic-header-parallax && npm pkg get version | tr -d '"')
22+
mkdir cypress
23+
cp -r $GITHUB_WORKSPACE/cypress/* ./cypress
24+
cp $GITHUB_WORKSPACE/cypress.config.ts .
25+
cp -r $GITHUB_WORKSPACE/src/app/home/* ./src/app/home
26+
npm i $GITHUB_WORKSPACE/dist/ionic-header-parallax/ionic-header-parallax-$PKG_VERSION.tgz
27+
ng serve --host 0.0.0.0 --port 4200 &
28+
(wait-on http://0.0.0.0:4200 --timeout 30000 --interval 1000 && cypress run --headless) \
29+
|| { echo 'Angular server failed to start'; exit 1; }

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ In the root folder:
1010
1. Run `npm run link` to point the demo app to use the local directive's source.
1111
2. Run `ng serve` to launch the demo app.
1212

13+
### Test
14+
1. Build: `npm run build -- -c production`
15+
2. Test with Docker: `bin/test.sh`
16+
17+

bin/test.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# Use this to test the angular project with cypress.
3+
# Execute from the project's root folder.
4+
5+
get_lib_version() {
6+
echo $(cd dist/ionic-header-parallax && npm pkg get version)
7+
}
8+
9+
run_test() {
10+
version=$1
11+
docker run \
12+
--rm \
13+
-v "$PWD:/project" \
14+
-v "$PWD/dist/ionic-header-parallax:/dist" \
15+
raschidjfr/ionic-blank:ionic8-angular19-cypress14 \
16+
bash -c "\
17+
mkdir cypress \
18+
&& cp -r /project/cypress/* ./cypress \
19+
&& cp /project/cypress.config.ts . \
20+
&& cp -r /project/src/app/home/* ./src/app/home \
21+
&& npm i /dist/ionic-header-parallax-$version.tgz \
22+
&& ng serve --host 0.0.0.0 --port 4200 \
23+
& (wait-on http://0.0.0.0:4200 && cypress run --headless) \
24+
|| { echo 'Angular server failed to start'; exit 1; }"
25+
}
26+
27+
lib_version=$(get_lib_version)
28+
run_test $lib_version
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)