ci-image-improvements (#18)
Reviewed-on: #18 Co-authored-by: David Gwilliam <dhgwilliam@gmail.com> Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
This commit was merged in pull request #18.
This commit is contained in:
@@ -13,10 +13,6 @@ jobs:
|
||||
options: --user root
|
||||
|
||||
steps:
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
apk add --no-cache bash git
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
@@ -30,7 +26,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: unit-tests
|
||||
container:
|
||||
image: node:20-alpine
|
||||
image: mcr.microsoft.com/playwright:v1.58.0-jammy
|
||||
options: --user root
|
||||
env:
|
||||
DATABASE_PROVIDER: sqlite
|
||||
@@ -38,18 +34,21 @@ jobs:
|
||||
BETTER_AUTH_SECRET: test-secret-key-for-ci-only
|
||||
|
||||
steps:
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
apk add --no-cache bash git
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Generate Prisma client
|
||||
run: npx prisma generate
|
||||
env:
|
||||
DATABASE_URL: postgresql://user:pass@localhost:5432/dummy
|
||||
|
||||
- name: Setup SQLite database
|
||||
run: |
|
||||
|
||||
@@ -15,10 +15,6 @@ jobs:
|
||||
if: "!contains(github.event.head_commit.message, 'chore: bump version')"
|
||||
|
||||
steps:
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
apk add --no-cache bash git
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
|
||||
@@ -127,6 +127,29 @@ npm run db:setup-postgres
|
||||
DATABASE_PROVIDER=sqlite DATABASE_URL=file:./prisma/ci.db npm run test:acceptance
|
||||
```
|
||||
|
||||
### CI Runner Image
|
||||
|
||||
**Note:** The CI runner image approach has been deprecated for Gitea Actions workflows.
|
||||
|
||||
The original attempt to use a pre-built CI runner image with pre-installed dependencies encountered fundamental issues with how Gitea Actions handles workspace mounting. When Gitea Actions runs a container job, it mounts the workspace at a specific path (e.g., `/workspace/david/euchre_camp`), which hides the container's `/app` directory where dependencies were installed.
|
||||
|
||||
**Current Approach:**
|
||||
- Workflows use standard `node:20-alpine` or `mcr.microsoft.com/playwright` containers
|
||||
- Dependencies are installed via `npm ci` in each workflow run
|
||||
- This is the recommended approach for Gitea Actions
|
||||
|
||||
**Why the CI image approach doesn't work:**
|
||||
1. Dockerfile.ci installs dependencies in `/app`
|
||||
2. Gitea Actions mounts workspace at `/workspace/david/euchre_camp`
|
||||
3. Workspace mount hides the `/app` directory
|
||||
4. Symlinks from `/app/node_modules` don't work because `/app` is hidden
|
||||
|
||||
**Alternative for performance:**
|
||||
If CI performance becomes an issue, consider:
|
||||
- Using GitHub Actions cache for node_modules
|
||||
- Using a self-hosted runner with persistent workspace
|
||||
- Using the main Dockerfile's `test-runner` target for release workflows (which works because it builds a complete image)
|
||||
|
||||
### CI/CD Pipeline
|
||||
The project uses Gitea Actions for continuous integration:
|
||||
|
||||
|
||||
@@ -368,11 +368,28 @@ The application uses Gitea Actions for continuous integration and deployment:
|
||||
- Unit tests for quick feedback
|
||||
- Skips auto-generated version bumps
|
||||
|
||||
3. **Release Workflow** (`.gitea/workflows/release.yml`): Runs on main branch pushes
|
||||
3. **Release Workflow** (`.gitea/workflows/release.yml`): Runs on main branch pushes
|
||||
- Version bumping and tagging
|
||||
- Docker image building and testing
|
||||
- Registry push and deployment
|
||||
|
||||
### CI Runner Image
|
||||
|
||||
**Note:** The CI runner image approach has been deprecated for Gitea Actions workflows.
|
||||
|
||||
The original attempt to use a pre-built CI runner image with pre-installed dependencies encountered fundamental issues with how Gitea Actions handles workspace mounting. When Gitea Actions runs a container job, it mounts the workspace at a specific path (e.g., `/workspace/david/euchre_camp`), which hides the container's `/app` directory where dependencies were installed.
|
||||
|
||||
**Current Approach:**
|
||||
- Workflows use standard `node:20-alpine` or `mcr.microsoft.com/playwright` containers
|
||||
- Dependencies are installed via `npm ci` in each workflow run
|
||||
- This is the recommended approach for Gitea Actions
|
||||
|
||||
**Why the CI image approach doesn't work:**
|
||||
1. Dockerfile.ci installs dependencies in `/app`
|
||||
2. Gitea Actions mounts workspace at `/workspace/david/euchre_camp`
|
||||
3. Workspace mount hides the `/app` directory
|
||||
4. Symlinks from `/app/node_modules` don't work because `/app` is hidden
|
||||
|
||||
### Database Strategy for CI
|
||||
- **CI Tests**: SQLite database (fast, no server required)
|
||||
- **Production**: PostgreSQL (production-like environment)
|
||||
|
||||
@@ -246,6 +246,8 @@ workflow-status:
|
||||
@echo "PR Workflow: Runs unit + acceptance tests on pull requests"
|
||||
@echo "Test Workflow: Runs unit tests on all branch pushes"
|
||||
@echo "Release Workflow: Runs on main branch pushes (version bump + Docker build)"
|
||||
@echo ""
|
||||
@echo "Note: CI image approach deprecated due to Gitea Actions workspace mounting"
|
||||
|
||||
# Check current database provider
|
||||
db-status:
|
||||
|
||||
Reference in New Issue
Block a user