Skip to content

Async entrypoints and jemalloc (#117) #169

Async entrypoints and jemalloc (#117)

Async entrypoints and jemalloc (#117) #169

Workflow file for this run

name: test
on:
pull_request: { types: [opened, reopened, synchronize, ready_for_review] }
push: { branches: [main] }
workflow_call:
outputs:
cache_key:
value: ${{ jobs.cache-toolbox.outputs.cache_key }}
env:
SWIFT_IMAGE: 'swift:5.9-jammy'
jobs:
# Check if a build of most recent release of the toolbox for the runner's OS and arch is cached, build and cache it if not
# Run for both PRs and pushes to main so every individual PR doesn't have to rebuild the toolbox at least once
# Use a concurrency group with no cancellation to avoid redundant builds; queued jobs will see the cache when they get their turn
cache-toolbox:
if: ${{ !(github.event.pull_request.draft || false) }}
concurrency:
group: cache_toolbox_for_template
cancel-in-progress: false
outputs:
cache_key: ${{ env.SWIFT_IMAGE }}-vapor-toolbox-${{ steps.latest.outputs.tag }}
runs-on: ubuntu-latest
steps:
- name: Get latest toolbox release
id: latest
run: 'echo "tag=$(curl -fsSL "https://api.github.com/repos/vapor/toolbox/releases/latest" | jq -r .tag_name)" >>"${GITHUB_OUTPUT}"'
- name: Check cache
id: check
uses: actions/cache@v3
with:
key: ${{ env.SWIFT_IMAGE }}-vapor-toolbox-${{ steps.latest.outputs.tag }}
path: toolbox
lookup-only: true
- name: Check out latest toolbox
if: ${{ !steps.check.outputs.cache-hit }}
uses: actions/checkout@v4
with:
repository: vapor/toolbox
ref: ${{ steps.latest.outputs.tag }}
- name: Build and cache toolbox
if: ${{ !steps.check.outputs.cache-hit }}
run: |
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
# 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:
if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.draft }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ toJSON(matrix) }}
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'
runs-on: ubuntu-latest
needs: cache-toolbox
steps:
- name: Get cached toolbox
uses: actions/cache/restore@v3
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: |
toolbox/vapor new template-test \
--template "${CLONE_URL}" --branch "${HEAD_REF}" \
--no-commit -o template-test \
${{ matrix.fluentflags }} ${{ matrix.leafflags }}
- name: Build and test template in container
run: |
docker run --rm -v "$(pwd)/template-test:/template-test" "${SWIFT_IMAGE}" bash -c 'swift test --package-path /template-test'
- name: Build Docker container
run: docker compose --project-directory template-test build