58 lines
1.5 KiB
YAML
58 lines
1.5 KiB
YAML
---
|
|
name: CI
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
jobs:
|
|
test:
|
|
name: Run Tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Setup QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
- name: Setup Docker buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
- name: Start MQTT.
|
|
run: >
|
|
docker run -d --name mosquitto \
|
|
-p "1883:1883" \
|
|
-p "8883:8883" \
|
|
-p "8080:8080" \
|
|
-p "8081:8081" \
|
|
eclipse-mosquitto:latest
|
|
# - name: Build the test image.
|
|
# uses: docker/build-push-action@v5
|
|
# with:
|
|
# context: .
|
|
# file: Dockerfile.test
|
|
# platforms: |
|
|
# linux/arm64
|
|
# linux/amd64
|
|
# push: true
|
|
# tags: |
|
|
# git.housh.dev/michael/${{ gitea.repository }}:${{ gitea.sha }}
|
|
- name: Get meta.
|
|
id: meta
|
|
run: |
|
|
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
|
|
|
- name: Build test image.
|
|
run: >
|
|
docker buildx build \
|
|
-file Dockerfile.test \
|
|
--tag ${{ steps.meta.outputs.REPO_NAME }}:test \
|
|
--load \
|
|
./
|
|
|
|
- name: Run Test
|
|
run: >
|
|
docker run --rm \
|
|
-e MOSQUITTO_SERVER=127.0.0.1 \
|
|
${{ steps.meta.outputs.REPO_NAME }}:test swift test
|
|
|
|
- name: Cleanup.
|
|
if: always()
|
|
run: docker stop mosquitto && docker rm -f mosquitto
|