Skip to content

Merge pull request #23099 from nvinuesa/task15-close-model-connections #3750

Merge pull request #23099 from nvinuesa/task15-close-model-connections

Merge pull request #23099 from nvinuesa/task15-close-model-connections #3750

name: "Static Analysis"
on:
push:
branches: ["[0-9].[0-9]+", "[0-9].[0-9]+.[0-9]+", main]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
# paths:
# DON'T SET - these are "required" so they need to run on every PR
workflow_dispatch:
jobs:
checks:
name: Checks
runs-on:
- self-hosted
- linux
- arm64
- ${{ (github.repository_owner == 'juju' && 'aws') || (github.repository_owner == 'canonical' && 'noble') }}
- ${{ (github.repository_owner == 'juju' && 'xxlarge') || (github.repository_owner == 'canonical' && 'xlarge') }}
if: github.event.pull_request.draft == false
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: "Squid"
if: github.repository_owner != 'juju'
run: ./.github/squid.sh
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- name: Install Dependencies
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
sudo add-apt-repository ppa:dqlite/dev -y --no-update
sudo apt-get update
sudo apt-get install -y \
expect \
libdqlite-dev \
libsqlite3-dev \
sqlite3
go install golang.org/x/vuln/cmd/govulncheck@latest
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/main/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.11.3
sudo curl -sSfL https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_$(go env GOARCH) -o /usr/bin/shfmt
sudo chmod +x /usr/bin/shfmt
go install github.com/google/go-licenses@latest
- name: Download Go Dependencies
run: go mod download
- name: "Static Analysis"
run: make static-analysis
sql:
name: SQL
runs-on: [self-hosted, linux, x64, aws, large]
if: github.event.pull_request.draft == false
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up Python
uses: "actions/setup-python@v5"
with:
python-version: "3.9"
- name: Install SQLFluff
run: "pip install sqlfluff==3.0.7"
- name: Lint SQL
run: "sqlfluff lint --config .github/.sqlfluff domain/schema/**/sql/*.sql"
conventional-commits:
name: Check conventional commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "22"
- name: Install commitlint
run: |
npm install --global @commitlint/cli@19.8.1 @commitlint/config-conventional@19.8.1
- name: Run commitlint
run: |
# For PRs, use the base branch to determine which commits to lint
# For push events, use the previous commit
if [ "${{ github.event_name }}" == "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
else
BASE_SHA="${{ github.event.before }}"
HEAD_SHA="${{ github.sha }}"
fi
# Get commits that are in HEAD but not in BASE
# Use --first-parent to follow only the first parent of merge commits
# This excludes commits brought in by merging other branches
COMMITS=$(git rev-list --first-parent --no-merges "${BASE_SHA}..${HEAD_SHA}")
if [ -z "$COMMITS" ]; then
echo "No commits to lint"
exit 0
fi
echo "Linting commits:"
echo "$COMMITS"
# Lint each commit
EXIT_CODE=0
for commit in $COMMITS; do
echo ""
echo "⧗ input: $(git log -1 --pretty=format:'%s' "$commit")"
if ! git log -1 --pretty=format:'%B' "$commit" | commitlint --config "${{ github.workspace }}/.github/commitlint.config.mjs" 2>&1; then
EXIT_CODE=1
fi
done
exit $EXIT_CODE