Skip to content

Commit

Permalink
Hopefully fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynne committed May 6, 2024
1 parent 553e952 commit f264abb
Showing 1 changed file with 66 additions and 6 deletions.
72 changes: 66 additions & 6 deletions .github/workflows/test-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ jobs:
docker run --rm -v "$(pwd):/toolbox-build" -w /toolbox-build "${SWIFT_IMAGE}" bash -c \
'swift build -c release --static-swift-stdlib --product vapor && mkdir toolbox && cp .build/release/vapor toolbox/vapor'
# Run vapor new and build the docker container for all combinations of options
# Run vapor new and test the template for all combinations of options
# Only run for PRs, running on push to main would be redundant.
# Use normal "only one of this workflow per branch at a time, cancel stale jobs" concurrency
test-new:
test-new-and-build:
if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.draft }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ toJSON(matrix) }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
swift-image:
- 'swift:5.10-jammy'
fluentflags:
- '--no-fluent'
- '--fluent.db mysql'
Expand All @@ -66,7 +68,28 @@ jobs:
- '--leaf'
- '--no-leaf'
runs-on: ubuntu-latest
container: ${{ matrix.swift-image }}
needs: cache-toolbox
services:
mongo: { image: 'mongo:latest' }
mysql:
image: mysql:latest
env: { MYSQL_ALLOW_EMPTY_PASSWORD: 'true', MYSQL_USER: test_username, MYSQL_PASSWORD: test_password, MYSQL_DATABASE: test_database }
psql:
image: postgres:latest
env: { POSTGRES_USER: test_username, POSTGRES_DB: test_database, POSTGRES_PASSWORD: test_password,
POSTGRES_HOST_AUTH_METHOD: 'scram-sha-256', POSTGRES_INITDB_ARGS: '--auth-host=scram-sha-256'
env:
MONGO_HOSTNAME: 'mongo'
MONGO_DATABASE: 'test_database'
MYSQL_HOSTNAME: 'mysql'
MYSQL_DATABASE: 'test_database'
MYSQL_USERNAME: 'test_username'
MYSQL_PASSWORD: 'test_password'
POSTGRES_HOSTNAME: 'psql'
POSTGRES_DB: 'test_database'
POSTGRES_USER: 'test_username'
POSTGRES_PASSWORD: 'test_password'
steps:
- name: Get cached toolbox
uses: actions/cache/restore@v4
Expand All @@ -83,8 +106,45 @@ jobs:
--template "${CLONE_URL}" --branch "${HEAD_REF}" \
--no-commit -o template-test \
${{ matrix.fluentflags }} ${{ matrix.leafflags }}
- name: Build and test template in container
- name: Build and test template
run: swift test --package-path /template-test'

# Run vapor new and build the container with Docker Compose for all combinations of options
# Only run for PRs, running on push to main would be redundant.
# Use normal "only one of this workflow per branch at a time, cancel stale jobs" concurrency
test-new-and-container:
if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.draft }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
fluentflags:
- '--no-fluent'
- '--fluent.db mysql'
- '--fluent.db postgres'
- '--fluent.db sqlite'
- '--fluent.db mongo'
leafflags:
- '--leaf'
- '--no-leaf'
needs: cache-toolbox
runs-on: ubuntu-latest
- name: Get cached toolbox
uses: actions/cache/restore@v4
with:
key: ${{ needs.cache-toolbox.outputs.cache_key }}
path: toolbox
fail-on-cache-miss: true
- name: Generate a project from the template
env:
HEAD_REF: ${{ github.head_ref }}
CLONE_URL: ${{ github.event.pull_request.head.repo.clone_url }}
run: |
docker run --rm -v "$(pwd)/template-test:/template-test" "${SWIFT_IMAGE}" bash -c 'swift test --package-path /template-test'
toolbox/vapor new template-test \
--template "${CLONE_URL}" --branch "${HEAD_REF}" \
--no-commit -o template-test \
${{ matrix.fluentflags }} ${{ matrix.leafflags }}
- name: Build Docker container
run: docker compose --project-directory template-test build
run: docker compose --project-directory template-test build

0 comments on commit f264abb

Please sign in to comment.