Skip to content

Commit

Permalink
Enable divviup-api in Kind integration tests (#72)
Browse files Browse the repository at this point in the history
- set the API handler as the default should none of the handlers
   registered in `OriginHandler` match
 - build and publish a container image built with feature
   `integration-test` to GAR
  • Loading branch information
tgeoghegan authored May 5, 2023
1 parent 9257d06 commit 468ea92
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ env:

jobs:
build-and-push:
strategy:
matrix:
image: [
{ name: "divviup_api", rust_features: "default" },
{ name: "divviup_api_integration_test", rust_features: "integration-testing" },
]
permissions:
id-token: write
contents: read
Expand All @@ -32,5 +38,12 @@ jobs:
password: ${{ steps.gcp-auth.outputs.access_token }}
- id: get_version
run: echo VERSION=${GITHUB_REF/refs\/tags\//} >> $GITHUB_OUTPUT
- run: docker build --tag us-west2-docker.pkg.dev/janus-artifacts/divviup-api/divviup_api:${{ steps.get_version.outputs.VERSION }} --build-arg GIT_REVISION=${GIT_REVISION} .
- run: docker push us-west2-docker.pkg.dev/janus-artifacts/divviup-api/divviup_api:${{ steps.get_version.outputs.VERSION }}
- run: |-
docker build \
--tag us-west2-docker.pkg.dev/janus-artifacts/divviup-api/${{ matrix.image.name }}:${{ steps.get_version.outputs.VERSION }} \
--build-arg RUST_FEATURES=${{ matrix.image.rust_features }} \
--build-arg GIT_REVISION=${GIT_REVISION} \
.
- run: |-
docker push \
us-west2-docker.pkg.dev/janus-artifacts/divviup-api/${{ matrix.image.name }}:${{ steps.get_version.outputs.VERSION }}
9 changes: 8 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ env:

jobs:
build:
strategy:
matrix:
rust-features: ["default", "integration-testing"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: echo "GIT_REVISION=$(git describe --always --dirty=-modified)" >> $GITHUB_ENV
- run: docker build --build-arg GIT_REVISION=${GIT_REVISION} .
- run: |-
docker build \
--build-arg GIT_REVISION=${GIT_REVISION} \
--build-arg RUST_FEATURES=${{ matrix.rust-features }} \
.
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ COPY build.rs /src/build.rs
COPY migration /src/migration
COPY src /src/src
RUN cd app && npm ci
RUN --mount=type=cache,target=/usr/local/cargo/registry --mount=type=cache,target=/src/target cargo build --profile release -p migration && cp /src/target/release/migration /migration
RUN --mount=type=cache,target=/usr/local/cargo/registry --mount=type=cache,target=/src/target cargo build --profile release && cp /src/target/release/divviup_api_bin /divviup_api_bin
ARG RUST_FEATURES=default
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/src/target \
cargo build --profile release -p migration && \
cp /src/target/release/migration /migration
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/src/target \
cargo build --profile release --features ${RUST_FEATURES} && \
cp /src/target/release/divviup_api_bin /divviup_api_bin

FROM alpine:3.17.3
ARG GIT_REVISION=unknown
Expand Down
5 changes: 2 additions & 3 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ impl DivviupApi {
caching_headers(),
conn_id(),
logger(),
origin_router()
.with_handler(config.app_url.as_ref(), static_assets(&config))
.with_handler(config.api_url.as_ref(), api(&db, &config)),
origin_router().with_handler(config.app_url.as_ref(), static_assets(&config)),
api(&db, &config),
ErrorHandler,
)),
db,
Expand Down

0 comments on commit 468ea92

Please sign in to comment.