Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move cargo-deny into a separate workflow on a schedule #10289

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actionlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ config-variables:
- SLACK_ON_CALL_QA_STAGING_STREAM
- DEV_AWS_OIDC_ROLE_MANAGE_BENCHMARK_EC2_VMS_ARN
- SLACK_ON_CALL_STORAGE_STAGING_STREAM
- SLACK_CARGO_DENY_CHANNEL
1 change: 1 addition & 0 deletions .github/file-filters.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
rust_code: ['**/*.rs', '**/Cargo.toml', '**/Cargo.lock']
rust_dependencies: ['**/Cargo.lock']

v14: ['vendor/postgres-v14/**', 'Makefile', 'pgxn/**']
v15: ['vendor/postgres-v15/**', 'Makefile', 'pgxn/**']
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/_check-codestyle-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,3 @@ jobs:
run: |
cargo hakari generate --diff # workspace-hack Cargo.toml is up-to-date
cargo hakari manage-deps --dry-run # all workspace crates depend on workspace-hack

# https://github.com/EmbarkStudios/cargo-deny
- name: Check rust licenses/bans/advisories/sources
if: ${{ !cancelled() }}
run: cargo deny check --hide-inclusion-graph
30 changes: 30 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,27 @@ jobs:
run cancel-previous-in-concurrency-group.yml \
--field concurrency_group="${{ env.E2E_CONCURRENCY_GROUP }}"

files-changed:
needs: [ check-permissions ]
name: Detect what files changed
runs-on: ubuntu-22.04
timeout-minutes: 3
outputs:
check-rust-dependencies: ${{ steps.files-changed.outputs.rust_dependencies }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Check for Postgres changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: files-changed
with:
token: ${{ github.token }}
filters: .github/file-filters.yaml

tag:
needs: [ check-permissions ]
runs-on: [ self-hosted, small ]
Expand Down Expand Up @@ -170,6 +191,14 @@ jobs:
archs: '["x64", "arm64"]'
secrets: inherit

check-dependencies-rust:
needs: [ check-permissions, files-changed, build-build-tools-image ]
if: ${{ needs.files-changed.outputs.check-rust-dependencies == 'true' }}
uses: ./.github/workflows/cargo-deny.yml
with:
build-tools-image: ${{ needs.build-build-tools-image.outputs.image }}-bookworm
secrets: inherit

build-and-test-locally:
needs: [ tag, build-build-tools-image ]
strategy:
Expand Down Expand Up @@ -1270,6 +1299,7 @@ jobs:
- build-and-test-locally
- check-codestyle-python
- check-codestyle-rust
- check-dependencies-rust
- promote-images-dev
- test-images
- trigger-custom-extensions-build-and-wait
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/cargo-deny.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: cargo deny checks

on:
workflow_call:
inputs:
build-tools-image:
required: false
type: string
schedule:
- cron: '0 0 * * *'

jobs:
cargo-deny:
strategy:
matrix:
ref: >-
${{
fromJSON(
github.event_name == 'schedule'
&& '["main","release","release-proxy","release-compute"]'
|| format('["{0}"]', github.sha)
)
}}

runs-on: [self-hosted, small]

container:
image: ${{ inputs.build-tools-image || 'neondatabase/build-tools:pinned' }}
credentials:
username: ${{ secrets.NEON_DOCKERHUB_USERNAME }}
password: ${{ secrets.NEON_DOCKERHUB_PASSWORD }}
options: --init

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ matrix.ref }}

- name: Check rust licenses/bans/advisories/sources
run: cargo deny check --hide-inclusion-graph ${{ github.event_name == 'schedule' && 'advisories' || 'all' }}

- name: Post to a Slack channel
if: ${{ github.event_name == 'schedule' && failure() }}
uses: slackapi/slack-github-action@v2
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ vars.SLACK_CARGO_DENY_CHANNEL }}
text: |
Periodic cargo-deny on ${{ matrix.ref }}: ${{ job.status }}
<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|GitHub Run>
Pinging @oncall-devprod.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading