From e55df04e362624e2f98274077a29ee65c8453070 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Fri, 1 Nov 2024 15:48:34 -0500 Subject: Lint ourselves Signed-off-by: Matt Strapp --- .github/workflows/beam.yml | 6 +-- .github/workflows/deno.yml | 4 ++ .github/workflows/docker.yml | 4 ++ .github/workflows/dotnet.yml | 10 +++-- .github/workflows/go.yml | 4 +- .github/workflows/jvm.yml | 8 ++-- .github/workflows/lint.yml | 90 -------------------------------------------- .github/workflows/node.yml | 6 +-- .github/workflows/ruby.yml | 8 ++-- .github/workflows/rust.yml | 10 +++-- 10 files changed, 37 insertions(+), 113 deletions(-) delete mode 100644 .github/workflows/lint.yml (limited to '.github/workflows') diff --git a/.github/workflows/beam.yml b/.github/workflows/beam.yml index a155c5d..c8785d7 100644 --- a/.github/workflows/beam.yml +++ b/.github/workflows/beam.yml @@ -13,8 +13,8 @@ on: - "**.beam" jobs: - build-and-test: - name: Build and Test + lint-build-and-test: + name: Lint, Build and Test runs-on: ubuntu-latest strategy: fail-fast: false @@ -35,7 +35,7 @@ jobs: run: mix test publish: name: Publish to hex.pm - needs: build-and-test + needs: lint-build-and-test # Only run on this on proper semver (vX.Y.Z) tags if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} runs-on: ubuntu-latest diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml index 357000b..3376864 100644 --- a/.github/workflows/deno.yml +++ b/.github/workflows/deno.yml @@ -26,6 +26,10 @@ jobs: uses: denoland/setup-deno@v2 with: deno-version: v2.x + - name: Lint + run: | + deno lint + deno fmt --check - name: Test run: deno test src/packages/locusts/mod.ts - name: Publish on Tag diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 9ae23f1..c35c7d4 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -29,6 +29,10 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Lint + uses: hadolint/hadolint-action@v3.1.0 + with: + dockerfile: Dockerfile - name: Extract metadata id: meta uses: docker/metadata-action@v5 diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 3b2fecb..6c525bd 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -15,8 +15,8 @@ on: - ".github/workflows/dotnet.yml" jobs: - build-and-test: - name: Build and Test + build-lint-and-test: + name: Lint, Build and Test runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -30,12 +30,14 @@ jobs: uses: actions/setup-dotnet@v4 - name: Install dependencies run: dotnet restore + - name: Lint + run: dotnet format --verify-no-changes - name: Test run: dotnet test --no-restore publish-preview: name: Publish Preview NuGet to GitHub Packages - needs: build-and-test + needs: build-lint-and-test if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} runs-on: ubuntu-latest permissions: @@ -61,7 +63,7 @@ jobs: publish-release: name: Publish Release NuGet to NuGet.org - needs: build-and-test + needs: build-lint-and-test # Only run on this on proper semver (vX.Y.Z) tags if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} runs-on: ubuntu-latest diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index da0bda4..6fbe548 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -13,8 +13,8 @@ on: - ".github/workflows/go.yml" jobs: - build-and-test: - name: Build and Test + lint-build-and-test: + name: Lint, Build and Test runs-on: ${{ matrix.os }} strategy: fail-fast: false diff --git a/.github/workflows/jvm.yml b/.github/workflows/jvm.yml index f3f9db7..2ea4fbc 100644 --- a/.github/workflows/jvm.yml +++ b/.github/workflows/jvm.yml @@ -17,8 +17,8 @@ on: - ".github/workflows/jvm.yml" jobs: - build-and-test: - name: Build and Test + lint-build-and-test: + name: Lint, Build and Test runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -41,7 +41,7 @@ jobs: publish-snapshot: name: Publish Snapshot to GitHub Packages - needs: build-and-test + needs: lint-build-and-test if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} runs-on: ubuntu-latest permissions: @@ -71,7 +71,7 @@ jobs: publish-release: name: Publish Packages to Maven Central and GitHub Packages - needs: build-and-test + needs: lint-build-and-test # Only run on this on proper semver (vX.Y.Z) tags if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} runs-on: ubuntu-latest diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 09e2970..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,90 +0,0 @@ -# MegaLinter GitHub Action configuration file -# More info at https://megalinter.io -name: Lint with MegaLinter - -on: - # Trigger mega-linter at every push. Action will also be visible from Pull Requests to main - push: # Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions) - pull_request: - branches: [master] - -env: # Comment env block if you don't want to apply fixes - # Apply linter fixes configuration - APPLY_FIXES: all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool) - APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all) - APPLY_FIXES_MODE: commit # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request) - -concurrency: - group: ${{ github.ref }}-${{ github.workflow }} - cancel-in-progress: true - -jobs: - megalinter: - name: MegaLinter - runs-on: ubuntu-latest - permissions: - # Give the default GITHUB_TOKEN write permission to commit and push, comment issues & post new PR - # Remove the ones you do not need - contents: write - issues: write - pull-requests: write - steps: - # Git Checkout - - name: Checkout Code - uses: actions/checkout@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - fetch-depth: 0 # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to improve performances - - # MegaLinter - - name: MegaLinter - id: ml - # You can override MegaLinter flavor used to have faster performances - # More info at https://megalinter.io/flavors/ - uses: oxsecurity/megalinter@v8 - env: - # All available variables are described in documentation - # https://megalinter.io/configuration/ - VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} # Validates all source when push on main, else just the git diff with main. Override with true if you always want to lint all sources - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY - # DISABLE: COPYPASTE,SPELL # Uncomment to disable copy-paste and spell checks - - # Upload MegaLinter artifacts - - name: Archive production artifacts - if: success() || failure() - uses: actions/upload-artifact@v4 - with: - name: MegaLinter reports - path: | - megalinter-reports - mega-linter.log - - # Create pull request if applicable (for now works only on PR from same repository, not from forks) - - name: Create Pull Request with applied fixes - id: cpr - if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - uses: peter-evans/create-pull-request@v7 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: "[MegaLinter] Apply linters automatic fixes" - title: "[MegaLinter] Apply linters automatic fixes" - labels: bot - - name: Create PR output - if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - run: | - echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" - - # Push new commit if applicable (for now works only on PR from same repository, not from forks) - - name: Prepare commit - if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - run: sudo chown -Rc $UID .git/ - - name: Commit and push applied linter fixes - if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - uses: stefanzweifel/git-auto-commit-action@v5 - with: - branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }} - commit_message: "[MegaLinter] Apply linters fixes" - commit_user_name: megalinter-bot - commit_user_email: nicolas.vuillamy@ox.security \ No newline at end of file diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 066986f..03cac87 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -23,8 +23,8 @@ on: - "**.svelte" jobs: - build-and-test: - name: Build and Test + lint-build-and-test: + name: Lint, Build and Test runs-on: ${{ matrix.os }} strategy: matrix: @@ -49,5 +49,5 @@ jobs: cache: "pnpm" - name: Check formatting run: pnpm lint - - name: Build and Test + - name: Lint, Build and Test run: pnpm build && pnpm test diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index b359a28..8ec504e 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -19,7 +19,7 @@ on: - ".github/workflows/ruby.yml" jobs: - build-and-test: + lint-build-and-test: runs-on: ubuntu-latest name: Ruby steps: @@ -29,12 +29,12 @@ jobs: with: ruby-version: ruby bundler-cache: true - - name: Build and test with Rake + - name: Lint, Build and Test with Rake run: bundle exec rake publish-preview: runs-on: ubuntu-latest - needs: build-and-test + needs: lint-build-and-test if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} name: Publish Preview to GitHub Package Registry permissions: @@ -64,7 +64,7 @@ jobs: publish-release: name: Push gem to RubyGems.org - needs: build-and-test + needs: lint-build-and-test # Only run on this on proper semver (vX.Y.Z) tags if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} runs-on: ubuntu-latest diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d95200a..2f86db0 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,8 +13,8 @@ on: - ".github/workflows/rust.yml" jobs: - build-and-test: - name: Build and Test + lint-build-test: + name: Lint, Lint, Build and Test runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -24,12 +24,16 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Lint + run: | + cargo fmt --all --check + cargo clippy - name: Test run: cargo test --verbose publish: name: Publish to crates.io - needs: build-and-test + needs: lint-build-test # Only run on this on proper semver (vX.Y.Z) tags if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} runs-on: ubuntu-latest -- cgit v1.2.3