diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 664a13f..abd21a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,246 +14,246 @@ jobs: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - with: - persist-credentials: false - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - name: Install dependencies - run: pip install PyOxidizer - - name: cargo check - run: cargo check - - name: cargo clippy - run: cargo clippy + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: Install dependencies + run: pip install PyOxidizer + - name: cargo check + run: cargo check + - name: cargo clippy + run: cargo clippy build-linux: name: Build Linux runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - with: - # To fetch tags, but can this be improved using blobless checkout? - # [1]. But anyway right it is not important, and unlikely will be, - # since the repository is small. - # - # [1]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ - fetch-depth: 0 - persist-credentials: false - - # Workaround for https://github.com/actions/checkout/issues/882 - - name: Fix tags for release - # will break on a lightweight tag - run: git fetch origin +refs/tags/*:refs/tags/* - - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - - name: Install dependencies - run: | - # Stick to the 0.23.0 due to issue with static linking on 0.24.0 [1]. - # [1]: https://github.com/indygreg/PyOxidizer/issues/673 - pip install PyOxidizer==0.23.0 - # nfpm - curl -sS -Lo /tmp/nfpm.deb "https://github.com/goreleaser/nfpm/releases/download/v2.25.0/nfpm_amd64.deb" - sudo dpkg -i /tmp/nfpm.deb - # for building cityhash for clickhouse-rs - sudo apt-get install -y musl-tools - # gcc cannot do cross compile, and there is no musl-g++ in musl-tools - sudo ln -srf /usr/bin/clang /usr/bin/musl-g++ - # musl for static binaries - rustup target add x86_64-unknown-linux-musl - - - name: Build - run: | - set -x - make packages target=x86_64-unknown-linux-musl - declare -A mapping - mapping[chdig*.x86_64.rpm]=chdig-latest.x86_64.rpm - mapping[chdig*-x86_64.pkg.tar.zst]=chdig-latest-x86_64.pkg.tar.zst - mapping[chdig*-x86_64.tar.gz]=chdig-latest-x86_64.tar.gz - mapping[chdig*_amd64.deb]=chdig-latest_amd64.deb - mapping[target/chdig]=chdig - for pattern in "${!mapping[@]}"; do - cp $pattern ${mapping[$pattern]} - done - - - name: Check package - run: | - sudo dpkg -i chdig-latest_amd64.deb - chdig --help - - - name: Archive Linux packages - uses: actions/upload-artifact@v3 - with: - name: linux-packages - path: | - chdig - *.deb - *.rpm - *.tar.* + - uses: actions/checkout@v3 + with: + # To fetch tags, but can this be improved using blobless checkout? + # [1]. But anyway right it is not important, and unlikely will be, + # since the repository is small. + # + # [1]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ + fetch-depth: 0 + persist-credentials: false + + # Workaround for https://github.com/actions/checkout/issues/882 + - name: Fix tags for release + # will break on a lightweight tag + run: git fetch origin +refs/tags/*:refs/tags/* + + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + + - name: Install dependencies + run: | + # Stick to the 0.23.0 due to issue with static linking on 0.24.0 [1]. + # [1]: https://github.com/indygreg/PyOxidizer/issues/673 + pip install PyOxidizer==0.23.0 + # nfpm + curl -sS -Lo /tmp/nfpm.deb "https://github.com/goreleaser/nfpm/releases/download/v2.25.0/nfpm_amd64.deb" + sudo dpkg -i /tmp/nfpm.deb + # for building cityhash for clickhouse-rs + sudo apt-get install -y musl-tools + # gcc cannot do cross compile, and there is no musl-g++ in musl-tools + sudo ln -srf /usr/bin/clang /usr/bin/musl-g++ + # musl for static binaries + rustup target add x86_64-unknown-linux-musl + + - name: Build + run: | + set -x + make packages target=x86_64-unknown-linux-musl + declare -A mapping + mapping[chdig*.x86_64.rpm]=chdig-latest.x86_64.rpm + mapping[chdig*-x86_64.pkg.tar.zst]=chdig-latest-x86_64.pkg.tar.zst + mapping[chdig*-x86_64.tar.gz]=chdig-latest-x86_64.tar.gz + mapping[chdig*_amd64.deb]=chdig-latest_amd64.deb + mapping[target/chdig]=chdig + for pattern in "${!mapping[@]}"; do + cp $pattern ${mapping[$pattern]} + done + + - name: Check package + run: | + sudo dpkg -i chdig-latest_amd64.deb + chdig --help + + - name: Archive Linux packages + uses: actions/upload-artifact@v3 + with: + name: linux-packages + path: | + chdig + *.deb + *.rpm + *.tar.* build-linux-no-features: name: Build Linux (no features) runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - with: - persist-credentials: false - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - name: Build - run: | - cargo build --no-default-features - - name: Check package - run: | - cargo run --no-default-features -- --help + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: Build + run: | + cargo build --no-default-features + - name: Check package + run: | + cargo run --no-default-features -- --help build-macos-x86_64: name: Build MacOS (x86_64) runs-on: macos-12 steps: - - uses: actions/checkout@v3 - with: - # To fetch tags, but can this be improved using blobless checkout? - # [1]. But anyway right it is not important, and unlikely will be, - # since the repository is small. - # - # [1]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ - fetch-depth: 0 - persist-credentials: false - - # Workaround for https://github.com/actions/checkout/issues/882 - - name: Fix tags for release - # will break on a lightweight tag - run: git fetch origin +refs/tags/*:refs/tags/* - - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - - name: Worker info - run: | - # SDKs versions - ls -al /Library/Developer/CommandLineTools/SDKs/ - - - name: Install dependencies - run: | - pip3 install PyOxidizer - - - name: Build - run: | - set -x - make deploy-binary - cp target/chdig chdig-macos-x86_64 - gzip --keep chdig-macos-x86_64 - - - name: Check package - run: | - ls -al - ./chdig-macos-x86_64 --help - - - name: Archive MacOS x86_64 packages - uses: actions/upload-artifact@v3 - with: - name: macos-packages-x86_64 - path: | - chdig-macos-x86_64.gz + - uses: actions/checkout@v3 + with: + # To fetch tags, but can this be improved using blobless checkout? + # [1]. But anyway right it is not important, and unlikely will be, + # since the repository is small. + # + # [1]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ + fetch-depth: 0 + persist-credentials: false + + # Workaround for https://github.com/actions/checkout/issues/882 + - name: Fix tags for release + # will break on a lightweight tag + run: git fetch origin +refs/tags/*:refs/tags/* + + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + + - name: Worker info + run: | + # SDKs versions + ls -al /Library/Developer/CommandLineTools/SDKs/ + + - name: Install dependencies + run: | + pip3 install PyOxidizer + + - name: Build + run: | + set -x + make deploy-binary + cp target/chdig chdig-macos-x86_64 + gzip --keep chdig-macos-x86_64 + + - name: Check package + run: | + ls -al + ./chdig-macos-x86_64 --help + + - name: Archive MacOS x86_64 packages + uses: actions/upload-artifact@v3 + with: + name: macos-packages-x86_64 + path: | + chdig-macos-x86_64.gz build-macos-arm64: name: Build MacOS (arm64) runs-on: macos-14 steps: - - uses: actions/checkout@v3 - with: - # To fetch tags, but can this be improved using blobless checkout? - # [1]. But anyway right it is not important, and unlikely will be, - # since the repository is small. - # - # [1]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ - fetch-depth: 0 - persist-credentials: false - - # Workaround for https://github.com/actions/checkout/issues/882 - - name: Fix tags for release - # will break on a lightweight tag - run: git fetch origin +refs/tags/*:refs/tags/* - - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - - name: Worker info - run: | - # SDKs versions - ls -al /Library/Developer/CommandLineTools/SDKs/ - - - name: Install dependencies - run: | - pip3 install PyOxidizer --break-system-packages - - - name: Build - run: | - set -x - make deploy-binary - cp target/chdig chdig-macos-arm64 - gzip --keep chdig-macos-arm64 - - - name: Check package - run: | - ls -al - ./chdig-macos-arm64 --help - - - name: Archive MacOS Arm64 packages - uses: actions/upload-artifact@v3 - with: - name: macos-packages-arm64 - path: | - chdig-macos-arm64.gz + - uses: actions/checkout@v3 + with: + # To fetch tags, but can this be improved using blobless checkout? + # [1]. But anyway right it is not important, and unlikely will be, + # since the repository is small. + # + # [1]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ + fetch-depth: 0 + persist-credentials: false + + # Workaround for https://github.com/actions/checkout/issues/882 + - name: Fix tags for release + # will break on a lightweight tag + run: git fetch origin +refs/tags/*:refs/tags/* + + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + + - name: Worker info + run: | + # SDKs versions + ls -al /Library/Developer/CommandLineTools/SDKs/ + + - name: Install dependencies + run: | + pip3 install PyOxidizer --break-system-packages + + - name: Build + run: | + set -x + make deploy-binary + cp target/chdig chdig-macos-arm64 + gzip --keep chdig-macos-arm64 + + - name: Check package + run: | + ls -al + ./chdig-macos-arm64 --help + + - name: Archive MacOS Arm64 packages + uses: actions/upload-artifact@v3 + with: + name: macos-packages-arm64 + path: | + chdig-macos-arm64.gz build-windows: name: Build Windows runs-on: windows-latest steps: - - uses: actions/checkout@v3 - with: - # To fetch tags, but can this be improved using blobless checkout? - # [1]. But anyway right it is not important, and unlikely will be, - # since the repository is small. - # - # [1]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ - fetch-depth: 0 - persist-credentials: false - - # Workaround for https://github.com/actions/checkout/issues/882 - - name: Fix tags for release - # will break on a lightweight tag - run: git fetch origin +refs/tags/*:refs/tags/* - - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - - name: Install dependencies - run: | - pip3 install PyOxidizer - - - name: Build - run: | - make deploy-binary - cp target/chdig.exe chdig-windows.exe - Compress-Archive -Path chdig-windows.exe -DestinationPath chdig-windows.exe.zip - - - name: Archive Windows packages - uses: actions/upload-artifact@v3 - with: - name: windows-packages - path: | - chdig-windows.exe.zip + - uses: actions/checkout@v3 + with: + # To fetch tags, but can this be improved using blobless checkout? + # [1]. But anyway right it is not important, and unlikely will be, + # since the repository is small. + # + # [1]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ + fetch-depth: 0 + persist-credentials: false + + # Workaround for https://github.com/actions/checkout/issues/882 + - name: Fix tags for release + # will break on a lightweight tag + run: git fetch origin +refs/tags/*:refs/tags/* + + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + + - name: Install dependencies + run: | + pip3 install PyOxidizer + + - name: Build + run: | + make deploy-binary + cp target/chdig.exe chdig-windows.exe + Compress-Archive -Path chdig-windows.exe -DestinationPath chdig-windows.exe.zip + + - name: Archive Windows packages + uses: actions/upload-artifact@v3 + with: + name: windows-packages + path: | + chdig-windows.exe.zip diff --git a/.github/workflows/pre_release.yml b/.github/workflows/pre_release.yml index 2ea1269..e56274a 100644 --- a/.github/workflows/pre_release.yml +++ b/.github/workflows/pre_release.yml @@ -4,7 +4,7 @@ name: pre-release on: push: branches: - - main + - main jobs: build: @@ -18,22 +18,22 @@ jobs: contents: write needs: - - build + - build steps: - - name: Download artifacts - uses: actions/download-artifact@v3 - - uses: "marvinpinto/action-automatic-releases@latest" - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - prerelease: true - automatic_release_tag: "latest" - title: "Development Build" - files: | - macos-packages-x86_64/chdig-macos-x86_64.gz - macos-packages-arm64/chdig-macos-arm64.gz - windows-packages/chdig-windows.exe.zip - linux-packages/chdig - linux-packages/*.deb - linux-packages/*.rpm - linux-packages/*.tar.* + - name: Download artifacts + uses: actions/download-artifact@v3 + - uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: true + automatic_release_tag: "latest" + title: "Development Build" + files: | + macos-packages-x86_64/chdig-macos-x86_64.gz + macos-packages-arm64/chdig-macos-arm64.gz + windows-packages/chdig-windows.exe.zip + linux-packages/chdig + linux-packages/*.deb + linux-packages/*.rpm + linux-packages/*.tar.* diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 85025b8..15ad627 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -4,14 +4,14 @@ name: pull_request on: pull_request: types: - - synchronize - - reopened - - opened + - synchronize + - reopened + - opened branches: - - main + - main paths-ignore: - - '**.md' - - 'Documentation/**' + - '**.md' + - 'Documentation/**' jobs: build: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index df64802..444025c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,7 @@ name: release on: push: tags: - - "v*" + - "v*" jobs: build: @@ -18,20 +18,20 @@ jobs: contents: write needs: - - build + - build steps: - - name: Download artifacts - uses: actions/download-artifact@v3 - - uses: "marvinpinto/action-automatic-releases@latest" - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - prerelease: false - files: | - macos-packages-x86_64/chdig-macos-x86_64.gz - macos-packages-arm64/chdig-macos-arm64.gz - windows-packages/chdig-windows.exe.zip - linux-packages/chdig - linux-packages/*.deb - linux-packages/*.rpm - linux-packages/*.tar.* + - name: Download artifacts + uses: actions/download-artifact@v3 + - uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: false + files: | + macos-packages-x86_64/chdig-macos-x86_64.gz + macos-packages-arm64/chdig-macos-arm64.gz + windows-packages/chdig-windows.exe.zip + linux-packages/chdig + linux-packages/*.deb + linux-packages/*.rpm + linux-packages/*.tar.* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 47e281c..3145298 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,22 +1,25 @@ --- repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 - hooks: - - id: check-byte-order-marker - - id: check-yaml - - id: end-of-file-fixer - - id: mixed-line-ending - - id: trailing-whitespace - - repo: https://github.com/pre-commit/pre-commit - rev: v3.6.0 - hooks: - - id: validate_manifest - - repo: https://github.com/doublify/pre-commit-rust - rev: v1.0 - hooks: - - id: fmt - - id: cargo-check - - id: clippy - # read [lints] directive from Config.toml - args: ["--", "-D", "warnings"] +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-byte-order-marker + - id: check-yaml + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace +- repo: https://github.com/pre-commit/pre-commit + rev: v3.6.0 + hooks: + - id: validate_manifest +- repo: https://github.com/doublify/pre-commit-rust + rev: v1.0 + hooks: + - id: fmt + pass_filenames: false + - id: cargo-check + - id: clippy +- repo: https://github.com/adrienverge/yamllint.git + rev: v1.35.1 + hooks: + - id: yamllint diff --git a/.yamllint b/.yamllint index 90d9514..5ea066e 100644 --- a/.yamllint +++ b/.yamllint @@ -3,9 +3,17 @@ extends: default rules: - indentation: - level: warning - indent-sequences: consistent - line-length: disable - # github-actions "on:" - truthy: disable + indentation: + spaces: 2 + level: error + indent-sequences: false + line-length: + max: 250 + braces: + max-spaces-inside: 1 + truthy: + allowed-values: ['true', 'false', 'yes', 'no'] + check-keys: true + comments: + # this is useful to distinguish commented code from comments + require-starting-space: false diff --git a/chdig-nfpm.yaml b/chdig-nfpm.yaml index da73821..242a873 100644 --- a/chdig-nfpm.yaml +++ b/chdig-nfpm.yaml @@ -11,15 +11,15 @@ description: | Dig into ClickHouse queries with TUI interface. contents: - - src: target/chdig - dst: /usr/bin/chdig - file_info: - mode: 0755 - - src: target/chdig.bash-completion - dst: /usr/share/bash-completion/completions/chdig - file_info: - mode: 0644 - - src: README.md - dst: /usr/share/doc/chdig/README.md - file_info: - mode: 0644 +- src: target/chdig + dst: /usr/bin/chdig + file_info: + mode: 0755 +- src: target/chdig.bash-completion + dst: /usr/share/bash-completion/completions/chdig + file_info: + mode: 0644 +- src: README.md + dst: /usr/share/doc/chdig/README.md + file_info: + mode: 0644