test: add live test #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Verify Dockerfile | |
on: push | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
- name: Prepare self-signed cert | |
run: | | |
# CA key and certificate | |
openssl genrsa -out CA.key 2048 | |
openssl req -new -x509 -nodes -key CA.key -sha256 -days 365 -extensions v3_ca -out CA.crt -subj '/OU=Nordic Developer Academy' | |
# Server key | |
openssl genrsa -out server.key 2048 | |
# CSR | |
openssl req -out server.csr -key server.key -new -subj '/CN=mqtt.academy.nordicsemi.com' | |
# Sign CSR | |
openssl x509 -req -in server.csr -CA CA.crt -CAkey CA.key -CAcreateserial -out server.crt -days 365 | |
- name: Build image | |
run: | | |
docker build -t academy-mqtt \ | |
. | |
- name: Run image | |
run: docker run -p 1883:1883 -p 8883:8883 -d academy-mqtt | |
- name: Install dependencies | |
run: npm ci | |
- name: Run tests | |
run: npx tsx --test test.ts |