rust-clippy analyze #30
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# rust-clippy is a tool that runs a bunch of lints to catch common | |
# mistakes in your Rust code and help improve your Rust code. | |
# More details at https://github.com/rust-lang/rust-clippy | |
# and https://rust-lang.github.io/rust-clippy/ | |
name: rust-clippy analyze | |
on: | |
push: | |
branches: [ "main", "*" ] | |
pull_request: | |
# The branches below must be a subset of the branches above | |
branches: [ "main", "*" ] | |
schedule: | |
- cron: '16 20 * * 3' | |
jobs: | |
rust-clippy-analyze: | |
name: Run rust-clippy analyzing | |
runs-on: ubuntu-latest | |
services: | |
# Label used to access the service container | |
postgres: | |
# Docker Hub image | |
image: postgres | |
# Provide the password for postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: postgres_db | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
# Maps tcp port 5432 on service container to the host | |
- 5432:5432 | |
permissions: | |
contents: read | |
security-events: write | |
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status | |
steps: | |
- name: Install PostgreSQL client | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y postgresql-client | |
# queries database with postgres client | |
- name: Create Database | |
run: psql -h localhost -d postgres -U postgres -c 'CREATE DATABASE "studentdb"' | |
env: | |
PGPASSWORD: postgres | |
- name: Create Table | |
run: psql -h localhost -d studentdb -U postgres -c 'CREATE TABLE | |
public.user_info ( | |
account_id serial NOT NULL, | |
first_name character varying(255) NOT NULL, | |
last_name character varying(255) NOT NULL, | |
username character varying(255) NOT NULL, | |
email character varying(255) NOT NULL, | |
active boolean NOT NULL DEFAULT false, | |
created_at timestamp without time zone NOT NULL DEFAULT now() | |
); | |
ALTER TABLE | |
public.user_info | |
ADD | |
CONSTRAINT student_info_pkey PRIMARY KEY (account_id)' | |
env: | |
PGPASSWORD: postgres | |
- name: Checkout code | |
uses: actions/checkout@v4.1.7 | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f #@v1.0.6 | |
with: | |
profile: minimal | |
toolchain: stable | |
components: clippy | |
override: true | |
- name: Install required cargo | |
run: cargo install clippy-sarif sarif-fmt | |
- name: Run rust-clippy | |
run: | |
cargo clippy | |
--all-features | |
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt | |
env: | |
DATABASE_URL: postgres://postgres:postgres@localhost:5432/studentdb | |
continue-on-error: true | |
- name: Upload analysis results to GitHub | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: rust-clippy-results.sarif | |
wait-for-processing: true |