Skip to content

Commit

Permalink
apply ci tests to node20 rock
Browse files Browse the repository at this point in the history
  • Loading branch information
Anas Husseini committed Mar 28, 2024
1 parent 2087eff commit 666e4dc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]

env:
node18-image: ubuntu/chiselled-node:18-test
node20-image: ubuntu/nodejs:20-test
ubuntu-release: 24.04

jobs:
Expand Down Expand Up @@ -35,20 +36,34 @@ jobs:
--output type=oci,dest="chiselled-node.${{ matrix.arch }}.tar" \
node18
- name: Build the ${{ env.node20-image }} image on ${{ matrix.arch }}
id: build
uses: canonical/craft-actions/rockcraft-pack@main
with:
path: node20/
verbosity: debug

- name: Run tests
if: ${{ matrix.arch == 'amd64' }}
run: |
set -ex
sudo apt-get update
sudo apt-get install -y skopeo
skopeo copy oci-archive:"chiselled-node.${{ matrix.arch }}.tar" docker-daemon:${{ env.node18-image }}
skopeo copy oci-archive:node20/nodejs_20_amd64.rock docker-daemon:${{ env.node20-image }}
./tests/run-all-tests ${{ env.node18-image }}
./tests/run-all-tests ${{ env.node20-image }}
- uses: actions/upload-artifact@v3
with:
name: chiselled-node-oci-tarballs
path: chiselled-node.*.tar

- uses: actions/upload-artifact@v3
with:
name: node-rocks
path: node20/*.rock

- id: set-outputs
if: always()
run: |
Expand Down
2 changes: 1 addition & 1 deletion tests/app_hello-world/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -ex
echo "Running test for Hello World app..."

test() {
docker run --rm -v "$PWD/src":/src:ro "$1" /src/main.js
docker run --rm -v "$PWD/src":/src:ro "$1" exec node /src/main.js
}

test "$NODE18"
2 changes: 1 addition & 1 deletion tests/app_http-server/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ echo "Running test for HTTP Server app..."

test() {
port=1234
container="$(docker run -d --rm -v "$PWD/src":/src:ro -p $port:8080 "$1" /src/main.js)"
container="$(docker run -d --rm -v "$PWD/src":/src:ro -p $port:8080 "$1" exec node /src/main.js)"
sleep 1
output="$(curl http://localhost:$port/)"
[ "$output" == "Hello world!" ] || exit 1
Expand Down
2 changes: 1 addition & 1 deletion tests/app_simple-modules/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build() {
}

test() {
docker run --rm -v "$PWD/dist":/src:ro "$1" /src/index.js
docker run --rm -v "$PWD/dist":/src:ro "$1" exec node /src/index.js
}

build
Expand Down
2 changes: 1 addition & 1 deletion tests/app_simple-typescript/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build() {

test() {
port=1234
container="$(docker run -d --rm -v "$PWD/dist":/src:ro -p $port:3000 "$1" /src/index.js)"
container="$(docker run -d --rm -v "$PWD/dist":/src:ro -p $port:3000 "$1" exec node /src/index.js)"
sleep 1
local output expected
output="$(curl http://localhost:$port/)"
Expand Down
2 changes: 1 addition & 1 deletion tests/app_simple-wasm/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build() {
}

test() {
docker run --rm -v "$PWD/dist":/src:ro "$1" /src/index.mjs
docker run --rm -v "$PWD/dist":/src:ro "$1" exec node /src/index.mjs
}

build
Expand Down

0 comments on commit 666e4dc

Please sign in to comment.