ci: add docker image test workflow (#332)

This commit is contained in:
spacecodeur
2025-01-27 13:29:08 -05:00
committed by GitHub
parent a16a313f71
commit 39dac5065f
2 changed files with 58 additions and 1 deletions
+57
View File
@@ -0,0 +1,57 @@
name: Docker CI
# If we need support more OS refer to
# https://github.com/tuono-labs/tuono/pull/332#issuecomment-2614439692
on:
push:
branches:
- 'main'
pull_request:
jobs:
build_and_test:
name: Build and Test Docker Image on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build and Run Docker Compose
run: |
docker compose -f docker/compose.yml up --build -d
- name: Check if the container is running
run: |
docker ps --filter "name=tuono-source-container" --format "table {{.Names}}\t{{.Status}}"
if ! docker ps --filter "name=tuono-source-container" --format "{{.Status}}" | grep -q "Up"; then
echo "Error: Container 'tuono-source-container' is not running."
exit 1
fi
- name: Check commands inside container
run: |
docker exec tuono-source-container pnpm --version || { echo "Error: pnpm is not available."; exit 1; }
docker exec tuono-source-container tuono --version || { echo "Error: tuono is not available."; exit 1; }
- name: Run cargo test
run: docker exec tuono-source-container cargo test
- name: Install node dependencies in each tuono's sub-projets
run: docker exec tuono-source-container bash -c 'for dir in /tuono/packages/*; do [ -d "$dir" ] && (cd "$dir" && yes | pnpm install --frozen-lockfile); done'
- name: Run pnpm test
run: docker exec tuono-source-container pnpm test
- name: Tear Down Docker Compose
if: always()
run: |
docker compose -f docker/compose.yml down --volumes
+1 -1
View File
@@ -16,7 +16,7 @@ COPY .nvmrc /tmp/.nvmrc
## Download the Node.js standelone binary archive && extract it && clean files ## Download the Node.js standelone binary archive && extract it && clean files
RUN ["/bin/sh", "-c", "NODE_VERSION=$(cat /tmp/.nvmrc) && \ RUN ["/bin/sh", "-c", "NODE_VERSION=$(cat /tmp/.nvmrc | tr -d '\r') && \
wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz && \ wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz && \
tar xf node-v${NODE_VERSION}-linux-x64.tar.xz --strip-components 1 && \ tar xf node-v${NODE_VERSION}-linux-x64.tar.xz --strip-components 1 && \
rm node-v${NODE_VERSION}-linux-x64.tar.xz /tmp/.nvmrc"] rm node-v${NODE_VERSION}-linux-x64.tar.xz /tmp/.nvmrc"]