Skip to content
Merged
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
103 changes: 103 additions & 0 deletions .github/workflows/assert-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Compiler checks

on:
workflow_call:
inputs:
candidate:
type: string
required: true
base:
type: string
required: true
nightly:
type: boolean
default: false

permissions:
contents: read

jobs:
compilers:
name: Build judge compilers
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
controls: ${{ steps.metadata.outputs.controls }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.candidate }}
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: minzc/go.mod
cache-dependency-path: minzc/go.sum
- name: Choose baseline and controls
id: metadata
env:
BASE_REV: ${{ inputs.base }}
NIGHTLY: ${{ inputs.nightly }}
run: bash scripts/ci/metadata.sh
- name: Build candidate and baseline
env:
BASE_SHA: ${{ steps.metadata.outputs.base }}
CI_BIN: ${{ runner.temp }}/judge-bin
run: bash scripts/ci/build.sh
- uses: actions/upload-artifact@v4
with:
name: judge-compilers
path: |
${{ runner.temp }}/judge-bin/*-mz
${{ runner.temp }}/judge-bin/base.tar.gz
retention-days: 7

checks:
name: ${{ inputs.nightly && matrix.job == 'fuzz' && 'Long fuzz' || matrix.name }}
needs: compilers
runs-on: ubuntu-latest
timeout-minutes: 40
continue-on-error: ${{ !inputs.nightly && matrix.job == 'sweep' }}
strategy:
fail-fast: false
matrix:
include:
- job: matrix
name: Assert matrix
- job: judges
name: Judge self-tests
- job: sweep
name: Default output sweep
- job: fuzz
name: Short fuzz
- job: fuzz-direct
name: Direct-call fuzz findings
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.candidate }}
- uses: actions/setup-go@v5
if: matrix.job == 'judges'
with:
go-version-file: minzc/go.mod
cache-dependency-path: minzc/go.sum
- uses: actions/download-artifact@v4
with:
name: judge-compilers
path: ${{ runner.temp }}/judge-bin
- name: Run judge
env:
CI_BIN: ${{ runner.temp }}/judge-bin
REPORT_DIR: ${{ runner.temp }}/reports/${{ matrix.job }}
CONTROLS: ${{ needs.compilers.outputs.controls }}
RUNS: ${{ inputs.nightly && '2' || '1' }}
FUZZ_COUNT: ${{ inputs.nightly && '10000' || '3000' }}
NIGHTLY: ${{ inputs.nightly }}
run: bash scripts/ci/run.sh '${{ matrix.job }}'
- name: Upload report and reproducers
if: always()
uses: actions/upload-artifact@v4
with:
name: compiler-${{ matrix.job }}-report
path: ${{ runner.temp }}/reports/${{ matrix.job }}/
if-no-files-found: warn
retention-days: 14
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,45 @@ jobs:
} else {
await github.rest.issues.createComment({ owner, repo, issue_number, body });
}

compiler_checks:
name: Compiler checks
uses: ./.github/workflows/assert-checks.yml
with:
candidate: ${{ github.sha }}
base: HEAD^1

advisory_lint:
name: Advisory Go lint
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 15
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '1.26.8'
cache-dependency-path: minzc/go.sum
- name: Cache pinned golangci-lint binary
id: lint-cache
uses: actions/cache@v4
with:
path: ~/go/bin/golangci-lint
key: golangci-lint-${{ runner.os }}-${{ runner.arch }}-v2.13.2-go1.26.8
- name: Install pinned golangci-lint
if: steps.lint-cache.outputs.cache-hit != 'true'
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.2
- name: Report new lint issues and changed-file formatting
env:
BASE_SHA: HEAD^1
REPORT_DIR: ${{ runner.temp }}/lint-report
run: bash scripts/ci/lint.sh
- uses: actions/upload-artifact@v4
if: always()
with:
name: advisory-lint-report
path: ${{ runner.temp }}/lint-report/
22 changes: 22 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Nightly compiler audit

on:
schedule:
- cron: '17 3 * * *'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: nightly-compiler-audit
cancel-in-progress: false

jobs:
compiler_checks:
name: Nightly compiler checks
uses: ./.github/workflows/assert-checks.yml
with:
candidate: ${{ github.sha }}
base: HEAD~1
nightly: true
84 changes: 8 additions & 76 deletions minzc/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,18 @@
version: "2"
run:
timeout: 5m
tests: true
skip-dirs:
- vendor
- testdata
skip-files:
- ".*_test.go"

linters:
default: none
enable:
- gofmt
- golint
- govet
- errcheck
- staticcheck
- gosimple
- errcheck
- ineffassign
- typecheck
- goconst
- gocyclo
- misspell
- unconvert
- goimports
- prealloc
- nakedret
- lll
- dupl
disable:
- godox # Allow TODO/FIXME comments
- funlen # Z80 code generation can have long functions
- gocognit # Complex optimization logic is acceptable

linters-settings:
govet:
check-shadowing: true
gocyclo:
min-complexity: 15
dupl:
threshold: 100
goconst:
min-len: 3
min-occurrences: 3
lll:
line-length: 120
nakedret:
max-func-lines: 30
prealloc:
simple: true
range-loops: true
for-loops: true

- unused
issues:
exclude-rules:
# Exclude some linters from running on test files
- path: _test\.go
linters:
- dupl
- gosec
- goconst

# Exclude generated files
- path: generated\.go
linters:
- golint
- stylecheck

# Allow complex functions in optimizer package
- path: pkg/optimizer/
linters:
- gocyclo
- gocognit

# Allow long lines in code generation
- path: pkg/codegen/
linters:
- lll

# Maximum issues count per one linter. Set to 0 to disable
max-issues-per-linter: 0

# Maximum count of issues with the same text. Set to 0 to disable
max-same-issues: 0

# Show only new issues created after git revision
new: false
output:
formats:
json:
path: stdout
Loading
Loading