fix: mount /apps and docker socket in PR workflow build-and-deploy-ci job (#41)
Reviewed-on: #41 Co-authored-by: David Gwilliam <dhgwilliam@gmail.com> Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
This commit was merged in pull request #41.
This commit is contained in:
@@ -8,6 +8,7 @@ on:
|
||||
- "Dockerfile.ci-base"
|
||||
- "package.json"
|
||||
- "bun.lock"
|
||||
- "package-lock.json"
|
||||
- ".gitea/workflows/build-ci-images.yml"
|
||||
schedule:
|
||||
# Weekly rebuild to get latest Playwright/Bun versions
|
||||
@@ -52,12 +53,13 @@ jobs:
|
||||
|
||||
- name: Build and push CI base image
|
||||
run: |
|
||||
# Build with multiple tags
|
||||
docker build \
|
||||
--file Dockerfile.ci-base \
|
||||
--tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:latest \
|
||||
--tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:playwright-${{ steps.meta.outputs.playwright_version }} \
|
||||
--tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:${{ github.sha }} \
|
||||
--push \
|
||||
.
|
||||
|
||||
- name: Clean up
|
||||
if: always()
|
||||
|
||||
@@ -40,12 +40,12 @@ jobs:
|
||||
|
||||
# Wait for production site to be healthy
|
||||
echo "Waiting for production site to be healthy..."
|
||||
for i in {1..30}; do
|
||||
for i in {1..6}; do
|
||||
if curl -sf https://euchre.notsosm.art/api/health > /dev/null 2>&1; then
|
||||
echo "✅ Production successfully deployed with version ${VERSION}"
|
||||
exit 0
|
||||
fi
|
||||
sleep 0.5
|
||||
sleep 15
|
||||
done
|
||||
echo "❌ Production deployment failed"
|
||||
docker compose logs app
|
||||
|
||||
+21
-15
@@ -15,21 +15,21 @@ jobs:
|
||||
container:
|
||||
image: docker.notsosm.art/euchre-camp/ci-base:latest
|
||||
options: --user root
|
||||
env:
|
||||
DATABASE_URL: postgresql://user:pass@localhost:5432/dummy
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
run: npm ci --legacy-peer-deps
|
||||
|
||||
- name: Generate Prisma client
|
||||
run: bun x prisma generate
|
||||
env:
|
||||
DATABASE_URL: postgresql://user:pass@localhost:5432/dummy
|
||||
run: npx prisma generate
|
||||
|
||||
- name: Run unit tests
|
||||
run: bun test src/__tests__/unit/ src/__tests__/*.test.tsx src/__tests__/auth-simple.test.ts
|
||||
run: npm test
|
||||
|
||||
build-and-deploy-ci:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -37,16 +37,20 @@ jobs:
|
||||
container:
|
||||
image: docker.notsosm.art/euchre-camp/ci-base:latest
|
||||
options: --user root
|
||||
volumes:
|
||||
- /var/lib/casaos/apps:/apps
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Required for acceptance tests - they import prisma via @/ path alias
|
||||
# and @cucumber/cucumber for cucumber-e2e tests
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
run: npm ci --legacy-peer-deps
|
||||
|
||||
- name: Generate Prisma client
|
||||
run: bun x prisma generate
|
||||
run: npx prisma generate
|
||||
env:
|
||||
DATABASE_URL: postgresql://user:pass@localhost:5432/dummy
|
||||
|
||||
@@ -73,33 +77,34 @@ jobs:
|
||||
# Update the image tag in the compose file
|
||||
sed -i "s|image: docker.notsosm.art/euchre-camp:[a-zA-Z0-9.-]*|image: docker.notsosm.art/euchre-camp:${IMAGE_TAG}|" ${COMPOSE_FILE}
|
||||
|
||||
# Pull the new image and restart the CI stack
|
||||
# Image was built locally in the previous step; compose uses it without pulling
|
||||
cd /apps/euchre_camp_ci
|
||||
docker compose pull app
|
||||
docker compose up -d app
|
||||
|
||||
- name: Wait for CI site to be healthy
|
||||
- name: Wait for CI site to be ready
|
||||
run: |
|
||||
for i in {1..30}; do
|
||||
echo "Waiting for Next.js to start..."
|
||||
sleep 20
|
||||
for i in {1..6}; do
|
||||
if curl -sf https://euchre-ci.notsosm.art/api/health > /dev/null 2>&1; then
|
||||
echo "CI site is healthy"
|
||||
exit 0
|
||||
fi
|
||||
sleep 0.5
|
||||
sleep 15
|
||||
done
|
||||
echo "CI site failed to become healthy after 15 seconds"
|
||||
echo "CI site failed to become healthy after 90 seconds"
|
||||
docker compose -f /apps/euchre_camp_ci/docker-compose.yml logs app
|
||||
exit 1
|
||||
|
||||
- name: Run acceptance tests
|
||||
run: DATABASE_URL="${{ secrets.CI_DATABASE_URL }}" bun test:acceptance
|
||||
run: DATABASE_URL="${{ secrets.CI_DATABASE_URL }}" npx playwright test e2e/
|
||||
env:
|
||||
CI: true
|
||||
|
||||
- name: Cleanup PR images
|
||||
if: always()
|
||||
run: |
|
||||
docker rmi ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:pr-${{ steps.info.outputs.pr_number }}-${{ steps.info.outputs.short_sha }} || true
|
||||
docker rmi --force ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:pr-${{ steps.info.outputs.pr_number }}-${{ steps.info.outputs.short_sha }} || true
|
||||
|
||||
analyze-bump-type:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -143,6 +148,7 @@ jobs:
|
||||
echo "reason=$REASON" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Comment bump type on PR
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
|
||||
@@ -73,10 +73,10 @@ jobs:
|
||||
echo "Bumping version: $BUMP"
|
||||
|
||||
# Run the bump script
|
||||
bun run scripts/bump-version.js "$BUMP" --yes
|
||||
node scripts/bump-version.js "$BUMP" --yes
|
||||
|
||||
# Get new version
|
||||
NEW_VERSION=$(bun -e "console.log(require('./package.json').version)")
|
||||
NEW_VERSION=$(node -e "console.log(require('./package.json').version)")
|
||||
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "New version: $NEW_VERSION"
|
||||
|
||||
@@ -121,8 +121,9 @@ jobs:
|
||||
run: |
|
||||
docker run --rm \
|
||||
-e DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" \
|
||||
-e NODE_ENV=test \
|
||||
${{ env.IMAGE_NAME }}-test:${{ steps.version.outputs.new_version }} \
|
||||
bun test 'src/__tests__/unit/**' 'src/__tests__/*.test.tsx' 'src/__tests__/auth-simple.test.ts'
|
||||
npm test
|
||||
|
||||
- name: Build production image
|
||||
if: steps.commit.outputs.committed == 'true'
|
||||
@@ -176,12 +177,12 @@ jobs:
|
||||
|
||||
# Wait for container to be healthy
|
||||
echo "Waiting for dev site to be healthy..."
|
||||
for i in {1..30}; do
|
||||
for i in {1..6}; do
|
||||
if curl -sf https://euchre-dev.notsosm.art/api/health > /dev/null 2>&1; then
|
||||
echo "✅ Dev environment successfully deployed with version ${{ steps.version.outputs.new_version }}"
|
||||
exit 0
|
||||
fi
|
||||
sleep 0.5
|
||||
sleep 15
|
||||
done
|
||||
echo "❌ Dev environment deployment failed"
|
||||
docker compose logs app
|
||||
|
||||
Reference in New Issue
Block a user