Skip to content

Commit

Permalink
chore(ci): Add precommit linting and scorecard workflows (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
YrrepNoj authored Mar 21, 2024
1 parent b08dbed commit dd479f0
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: lint
on: [pull_request]

# Declare default permissions as read only.
permissions: read-all

jobs:
ruff:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Validate Lint
uses: chartboost/ruff-action@e18ae971ccee1b2d7bbef113930f00c670b78da4 # v1.0.0
with:
version: 0.2.2

- name: Validate Formatting
uses: chartboost/ruff-action@e18ae971ccee1b2d7bbef113930f00c670b78da4 # v1.0.0
with:
version: 0.2.2
args: format --check
51 changes: 51 additions & 0 deletions .github/workflows/scorecard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: OpenSSF Scorecared
on:
# Only the default branch is supported.
branch_protection_rule:
schedule:
- cron: '20 3 * * 0' # Every Sunday at 03:20 UTC

push:
branches: [ "main" ]

# Declare default permissions as read only.
permissions: read-all

jobs:
analysis:
name: Scorecards analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Used to receive a badge.
id-token: write

steps:
- name: "Checkout code"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
with:
results_file: results.sarif
results_format: sarif
repo_token: ${{ secrets.GITHUB_TOKEN }} # Secret is for validating branch rules
publish_results: true

# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12
with:
sarif_file: results.sarif
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
repos:
# Generic pre-commit checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-added-large-files
args: ["--maxkb=1024"]
- id: check-merge-conflict
- id: detect-aws-credentials
args:
- "--allow-missing-credentials"
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

# Python linting and formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff # Run the linter.
- id: ruff-format # Run the formatter.

# Zarf schema validation
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.14.0
hooks:
- id: check-jsonschema
name: "Validate Zarf Configs Against Schema"
files: "zarf.yaml"
types: [yaml]
args: ["--schemafile", "https://github.com/defenseunicorns/zarf/blob/main/zarf.schema.json"]
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![LeapfrogAI Logo](https://github.com/defenseunicorns/leapfrogai/raw/main/docs/imgs/leapfrogai.png)

[![](https://dcbadge.vercel.app/api/server/s2Ja5cmZRQ)](https://discord.gg/s2Ja5cmZRQ)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/leapfrogai/badge)](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/leapfrogai)

## Table of Contents
- [Table of Contents](#table-of-contents)
Expand All @@ -13,6 +13,7 @@
- [Image Hardening](#image-hardening)
- [SDK](#sdk)
- [User Interface](#user-interface)
- [Advanced Deployments](#advanced-deployments)
- [Community](#community)

## Overview
Expand Down

0 comments on commit dd479f0

Please sign in to comment.