Skip to content

fix: improve JSON/YAML diff output; fix upgradeRisk edge case (#1433) #4260

fix: improve JSON/YAML diff output; fix upgradeRisk edge case (#1433)

fix: improve JSON/YAML diff output; fix upgradeRisk edge case (#1433) #4260

Workflow file for this run

# Copyright 2024 Chainguard, Inc.
# SPDX-License-Identifier: Apache-2.0
name: Code Style
env:
GO_RELEASE: "go-1.26"
YARA_X_RELEASE: "1.14.0"
permissions: {}
on:
pull_request:
branches:
- "main"
push:
branches:
- "main"
jobs:
yrcompile:
name: check yr compile
runs-on: ubuntu-24.04-arm
permissions:
contents: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Run make yara-x-compile
run: |
make yara-x-compile
ret=$?
if [[ $ret -ne 0 ]]; then
echo "Rule compilation failed; address findings and commit the changes"
exit 1
fi
yrfmt:
name: check yr fmt
runs-on: ubuntu-24.04-arm
permissions:
contents: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install yara-x
run: |
wget https://github.com/VirusTotal/yara-x/releases/download/v${{ env.YARA_X_RELEASE }}/yara-x-v${{ env.YARA_X_RELEASE }}-aarch64-unknown-linux-gnu.gz -O yara-x.gz
gunzip yara-x.gz && tar -xvf yara-x && chmod +x yr && mv yr /usr/local/bin/ && rm yara-x
- name: Verify yr installation
run: |
yr --version
- name: Run yr fmt
run: |
find rules -type f -name "*.yara" | xargs -n 1 -I {} yr fmt {}
if [[ -n $(git status -s) ]]; then
echo "Rule files updated; please run yr fmt locally and commit the changes"
exit 1
fi
gofmt:
name: check gofmt
runs-on: ubuntu-24.04-arm
permissions:
contents: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
check-latest: true
- uses: chainguard-dev/actions/gofmt@7440e20e3e0bb180a2f6e330bcd53504e2ac8980 # main
with:
args: -s
goimports:
name: check goimports
runs-on: ubuntu-24.04-arm
permissions:
contents: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
check-latest: true
- uses: chainguard-dev/actions/goimports@7440e20e3e0bb180a2f6e330bcd53504e2ac8980 # main
golangci-lint:
name: golangci-lint
runs-on: ubuntu-24.04-arm
permissions:
contents: read
container:
image: cgr.dev/chainguard/wolfi-base:latest
options: >-
--cap-add DAC_OVERRIDE
--cap-add SETGID
--cap-add SETUID
--cap-drop ALL
--cgroupns private
--cpu-shares=4096
--memory-swappiness=0
--security-opt no-new-privileges
--ulimit core=0
--ulimit nofile=4096:4096
--ulimit nproc=4096:4096
steps:
- name: Install dependencies
run: |
apk update
apk add curl findutils git ${{ env.GO_RELEASE }} nodejs yara-x~${{ env.YARA_X_RELEASE }}
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Trust repository
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Run golangci-lint
run: |
make golangci-lint-lint