Skip to content

pipeline

pipeline #24

Workflow file for this run

name: "Test"
on:
push:
pull_request:
jobs:
sqlx:
name: "Verify Sqlx Cache"
runs-on: "ubuntu-latest"
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
ports:
- 5432:5432
env:
DATABASE_URL: "postgres://postgres:password@localhost/postgres"
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
- name: "Setup Protoc"
uses: arduino/setup-protoc@v3
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- name: "Install SqlX"
run: cargo install sqlx-cli
- name: "Configure the database"
run: cargo sqlx database reset
- name: "Check the sqlx cache"
run: cargo sqlx prepare --check --workspace
check:
name: "Cargo check"
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
- name: "Setup Protoc"
uses: arduino/setup-protoc@v3
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- run: "cargo check"
test:
name: "Cargo test"
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
- name: "Setup Protoc"
uses: arduino/setup-protoc@v3
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- run: "cargo test --lib"
fmt:
name: "Cargo format"
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- run: "rustup component add rustfmt"
- run: "cargo fmt --all -- --check"
clippy:
name: "Cargo clippy"
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
- name: "Setup Protoc"
uses: arduino/setup-protoc@v3
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- run: "rustup component add clippy"
- run: "cargo clippy -- -D warnings"
create-tag:
name: "Create tag"
runs-on: "ubuntu-latest"
needs:
- sqlx
- check
- test
- fmt
- clippy
permissions:
contents: write
if: github.ref == 'refs/heads/main'
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: "Get tag"
id: "get-tag"
shell: "bash"
run: |
echo PKG_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' ocpp/Cargo.toml) >> $GITHUB_OUTPUT
- name: "Set Tag"
shell: "bash"
run: |
git tag v${{ steps.get-tag.outputs.PKG_VERSION }} || true
- name: "Push Tags"
shell: "bash"
run: git push --tags || true