CI #395
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
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: '30 3 * * 2' | |
name: CI | |
jobs: | |
backend: | |
name: Build and test backend | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: mdillon/postgis:11 | |
env: | |
POSTGRES_USER: flugbuech | |
POSTGRES_PASSWORD: flugbuech | |
POSTGRES_DB: flugbuech_test | |
ports: | |
- 5432:5432 | |
# Needed because the postgres container does not provide a healthcheck | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- uses: actions/checkout@v2 | |
- run: sudo apt-get install -y libpq-dev | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.59.0 | |
override: true | |
- name: Run check | |
uses: actions-rs/cargo@v1 | |
with: | |
command: check | |
args: --all-features | |
- name: Run tests | |
uses: actions-rs/cargo@v1 | |
env: | |
TEST_DATABASE_URL: 'postgres://flugbuech:flugbuech@localhost:5432/flugbuech_test' | |
with: | |
command: test | |
args: --all-features | |
frontend: | |
name: Build frontend | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: '12' | |
- run: npm install | |
- run: npm run build | |
clippy: | |
name: Run clippy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- run: sudo apt-get install -y libpq-dev | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.59.0 | |
components: clippy | |
override: true | |
- uses: actions-rs/clippy-check@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
args: --all-features | |
rustfmt: | |
name: Check code formatting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.59.0 | |
components: rustfmt | |
override: true | |
- run: cargo fmt -- --check | |
#eslint: Disabled until https://github.com/sveltejs/eslint-plugin-svelte3/issues/10 is fixed | |
# name: Run eslint | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v2 | |
# - uses: actions/setup-node@v1 | |
# with: | |
# node-version: '12' | |
# - run: npm install | |
# - run: npm run lint | |
docker_image: | |
name: Build Docker image | |
runs-on: ubuntu-latest | |
needs: [backend, frontend] | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build Docker image | |
run: | | |
docker build \ | |
--no-cache \ | |
-t dbrgn/flugbuech:latest \ | |
-t dbrgn/flugbuech:main \ | |
. | |
- name: Push Docker image | |
run: | | |
docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_PASSWORD }}" && \ | |
docker push dbrgn/flugbuech:main && \ | |
docker push dbrgn/flugbuech:latest |