Add test for running the Docker image on CI #109
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Based on https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md | |
name: Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v2 | |
- name: Install stable toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: 1.70.0 | |
override: true | |
components: clippy, rustfmt | |
- uses: Swatinem/rust-cache@v1 | |
- name: Check | |
uses: actions-rs/cargo@v1 | |
with: | |
command: check | |
args: --all --all-targets | |
- name: Test | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: --all | |
- name: Lint code | |
uses: actions-rs/cargo@v1 | |
with: | |
command: clippy | |
args: --all | |
- name: Check formatting | |
uses: actions-rs/cargo@v1 | |
with: | |
command: fmt | |
args: --all -- --check | |
docker: | |
name: Test Docker | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- uses: docker/setup-buildx-action@v2 | |
- name: Build the Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: bors | |
load: true | |
- name: Run Docker image | |
run: | | |
# Check that the service starts | |
docker run bors & | |
timeout 20 bash -c 'until nc -z localhost 8080; do sleep 1; done' |