From 865d0dac786ca1fd8662899d42a4d24d741ac6a3 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Sat, 2 Oct 2021 21:32:27 -0400 Subject: [PATCH 01/13] other: remove redundant line in rustfmt --- rustfmt.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/rustfmt.toml b/rustfmt.toml index 61aee1cc..03574d14 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,3 @@ -edition = "2018" reorder_imports = true reorder_modules = true merge_derives = true From 9071e372834c92304bf104ae827971c48dbac6d1 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Sun, 3 Oct 2021 02:42:37 -0400 Subject: [PATCH 02/13] ci: only create nightly release if build passes (#590) Changes the nightly build workflow to delete/create a new release *only* if the entire build process passes. This avoids a potential case of a nightly build failing but having overwritten the old one, which has happened before. After this change lands, similar changes will probably be made to the deployment script for releases. --- .github/workflows/deployment.yml | 2 +- .github/workflows/nightly.yml | 196 ++++++++---------- deployment/windows/choco/choco_packager.py | 2 +- ...mplate => chocolatey_install.ps1.template} | 0 4 files changed, 91 insertions(+), 109 deletions(-) rename deployment/windows/choco/{chocolateyinstall.ps1.template => chocolatey_install.ps1.template} (100%) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 3cf29c6a..70fd7d5a 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -450,7 +450,7 @@ jobs: - name: Execute choco packaging script run: | - python "./deployment/windows/choco/choco_packager.py" "./artifacts/bottom_i686-pc-windows-msvc.zip" "./artifacts/bottom_x86_64-pc-windows-msvc.zip" ${{ env.RELEASE_VERSION }} "./deployment/windows/choco/bottom.nuspec.template" "./deployment/windows/choco/chocolateyinstall.ps1.template" "bottom.nuspec" "tools/chocolateyinstall.ps1" "tools/" + python "./deployment/windows/choco/choco_packager.py" "./artifacts/bottom_i686-pc-windows-msvc.zip" "./artifacts/bottom_x86_64-pc-windows-msvc.zip" ${{ env.RELEASE_VERSION }} "./deployment/windows/choco/bottom.nuspec.template" "./deployment/windows/choco/chocolatey_install.ps1.template" "bottom.nuspec" "tools/chocolatey_install.ps1" "tools/" zip -r choco.zip "bottom.nuspec" "tools" - name: Upload choco.zip to release diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1a012253..2b07acc7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -14,13 +14,10 @@ on: required: false jobs: - create-github-release: - name: create-github-release + initialize-job: + name: initialize-job runs-on: ubuntu-latest steps: - - name: Create artifacts directory - run: mkdir artifacts - - name: Check if mock run: | echo "${{ github.event.inputs.isMock }}"; @@ -32,45 +29,19 @@ jobs: echo "This is NOT a mock run. Watch for the generated files!" fi - - name: Delete tag and release - uses: dev-drprasad/delete-tag-and-release@v0.1.3 - if: github.event.inputs.isMock != 'mock' - with: - delete_release: true - tag_name: nightly - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Sleep for a few seconds to prevent timing issues between the deletion and creation of the release - run: sleep 10 - - - name: Create nightly GitHub release - id: release - uses: actions/create-release@v1 - if: github.event.inputs.isMock != 'mock' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - draft: false - tag_name: nightly - release_name: nightly - prerelease: true - - - name: Save release upload URL to artifact - run: echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url - - name: Save version number to artifact - run: echo "nightly" > artifacts/release-version + run: echo "nightly" > release-version - - name: Upload artifacts - uses: actions/upload-artifact@v1 + - name: Upload release-version as artifact + uses: actions/upload-artifact@v2 with: - name: artifacts - path: artifacts + retention-days: 1 + name: release-version + path: release-version build-release: name: build-release - needs: [create-github-release] + needs: [initialize-job] runs-on: ${{ matrix.triple.os }} container: ${{ matrix.triple.container }} env: @@ -164,25 +135,6 @@ jobs: with: fetch-depth: 1 - - name: Get release download URL - uses: actions/download-artifact@v2 - with: - name: artifacts - path: artifacts - - - name: Set release upload URL and release version - shell: bash - run: | - release_upload_url="$(cat ./artifacts/release-upload-url)" - echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV - release_version="$(cat ./artifacts/release-version)" - echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - - - name: Validate release environment variables - run: | - echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}" - echo "Release version: ${{ env.RELEASE_VERSION }}" - - name: Install toolchain uses: actions-rs/toolchain@v1 with: @@ -232,38 +184,29 @@ jobs: tar -czvf bottom_${{ matrix.triple.target }}${{ matrix.triple.suffix }}.tar.gz btm completion echo "ASSET=bottom_${{ matrix.triple.target }}${{ matrix.triple.suffix }}.tar.gz" >> $GITHUB_ENV - - name: Upload main release - if: github.event.inputs.isMock != 'mock' - uses: actions/upload-release-asset@v1.0.1 - id: upload - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ env.RELEASE_UPLOAD_URL }} - asset_path: ${{ env.ASSET }} - asset_name: ${{ env.ASSET }} - asset_content_type: application/octet-stream + - name: Create release directory for artifact, move file + shell: bash + run: | + mkdir release + mv ${{ env.ASSET }} release - name: Compress completion files (Linux x86-64 GNU) if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' shell: bash run: | tar -C ./completion -czvf completion.tar.gz . + mv completion.tar.gz release - - name: Release completion files (Linux x86-64 GNU) - if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' && github.event.inputs.isMock != 'mock' - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Save release files as artifacts + uses: actions/upload-artifact@v2 with: - upload_url: ${{ env.RELEASE_UPLOAD_URL }} - asset_path: completion.tar.gz - asset_name: completion.tar.gz - asset_content_type: application/octet-stream + retention-days: 1 + name: release + path: release build-msi: name: build-msi - needs: [create-github-release] + needs: [initialize-job] runs-on: "windows-2019" env: RUST_BACKTRACE: 1 @@ -276,20 +219,17 @@ jobs: - name: Get release download URL uses: actions/download-artifact@v2 with: - name: artifacts - path: artifacts + name: release-version + path: release-version - - name: Set release upload URL and release version + - name: Set release version shell: bash run: | - release_upload_url="$(cat ./artifacts/release-upload-url)" - echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV - release_version="$(cat ./artifacts/release-version)" + release_version="$(cat ./release-version/release-version)" echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - name: Validate release environment variables run: | - echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}" echo "Release version: ${{ env.RELEASE_VERSION }}" - name: Install Net-Framework-Core @@ -320,20 +260,22 @@ jobs: cargo wix init cargo wix - - name: Upload msi file - if: github.event.inputs.isMock != 'mock' - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create release directory for artifact, move file + shell: bash + run: | + mkdir release + mv bottom_x86_64_installer.msi release + + - name: Save msi file as artifacts + uses: actions/upload-artifact@v2 with: - upload_url: ${{ env.RELEASE_UPLOAD_URL }} - asset_path: bottom_x86_64_installer.msi - asset_name: bottom_x86_64_installer.msi - asset_content_type: application/octet-stream + retention-days: 1 + name: release + path: release build-deb: name: build-deb - needs: [create-github-release] + needs: [initialize-job] runs-on: "ubuntu-18.04" env: RUST_BACKTRACE: 1 @@ -346,20 +288,17 @@ jobs: - name: Get release download URL uses: actions/download-artifact@v2 with: - name: artifacts - path: artifacts + name: release-version + path: release-version - name: Set release upload URL and release version shell: bash run: | - release_upload_url="$(cat ./artifacts/release-upload-url)" - echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV - release_version="$(cat ./artifacts/release-version)" + release_version="$(cat ./release-version/release-version)" echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - name: Validate release environment variables run: | - echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}" echo "Release version: ${{ env.RELEASE_VERSION }}" - name: Install toolchain @@ -380,13 +319,56 @@ jobs: cargo deb cp ./target/debian/bottom_*.deb ./bottom_${{ env.RELEASE_VERSION }}_amd64.deb - - name: Upload Debian file if not mock + - name: Create release directory for artifact, move file + shell: bash + run: | + mkdir release + mv bottom_${{ env.RELEASE_VERSION }}_amd64.deb release + + - name: Save Debian file as artifacts + uses: actions/upload-artifact@v2 + with: + retention-days: 1 + name: release + path: release + + upload-release: + name: upload-release + runs-on: ubuntu-latest + needs: [build-release, build-deb, build-msi] + steps: + - name: Get release artifacts + uses: actions/download-artifact@v2 + with: + name: release + path: release + + - name: Print out all release files + run: | + echo "Generated $(ls ./release | wc -l) files:" + ls ./release + + - name: Delete tag and release + uses: dev-drprasad/delete-tag-and-release@v0.1.3 if: github.event.inputs.isMock != 'mock' - uses: actions/upload-release-asset@v1.0.1 + with: + delete_release: true + tag_name: nightly env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Sleep for a few seconds to prevent timing issues between the deletion and creation of the release + run: sleep 10 + if: github.event.inputs.isMock != 'mock' + + - name: Upload all saved release files if not mock + uses: softprops/action-gh-release@v1 + if: github.event.inputs.isMock != 'mock' with: - upload_url: ${{ env.RELEASE_UPLOAD_URL }} - asset_path: bottom_${{ env.RELEASE_VERSION }}_amd64.deb - asset_name: bottom_${{ env.RELEASE_VERSION }}_amd64.deb - asset_content_type: application/octet-stream + token: ${{ secrets.GITHUB_TOKEN }} + prerelease: true + tag_name: "nightly" + draft: false + fail_on_unmatched_files: true + files: | + ./release/* diff --git a/deployment/windows/choco/choco_packager.py b/deployment/windows/choco/choco_packager.py index 1e5c5684..da8e2960 100644 --- a/deployment/windows/choco/choco_packager.py +++ b/deployment/windows/choco/choco_packager.py @@ -49,7 +49,7 @@ with open(deployment_file_path_32, "rb") as deployment_file_32, open( with open(ps1_template, "r") as template_file: template = Template(template_file.read()) substitute = template.safe_substitute(version=version, hash_32=hash_32, hash_64=hash_64) - print("\n================== Generated chocolateyinstall file ==================\n") + print("\n================== Generated chocolatey-install file ==================\n") print(substitute) print("\n============================================================\n") diff --git a/deployment/windows/choco/chocolateyinstall.ps1.template b/deployment/windows/choco/chocolatey_install.ps1.template similarity index 100% rename from deployment/windows/choco/chocolateyinstall.ps1.template rename to deployment/windows/choco/chocolatey_install.ps1.template From 3c51245d35b8f044026a065578de56982d2f2381 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Sun, 3 Oct 2021 16:44:50 -0400 Subject: [PATCH 03/13] ci: Disable cross for i686 Windows, add multilib for i686 Linux for Nightly (#592) Disables an unnecessary use of cross for i686 Windows, and add multilib for i686 Linux since apparently that's needed now. --- .github/workflows/nightly.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2b07acc7..c94bbf9b 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -68,7 +68,7 @@ jobs: - { os: "ubuntu-18.04", target: "i686-unknown-linux-gnu", - cross: true, + cross: false, strip: true, } - { @@ -143,6 +143,13 @@ jobs: override: true target: ${{ matrix.triple.target }} + - name: Install gcc-multilib for (Linux i686) + if: matrix.triple.target == 'i686-unknown-linux-gnu' || matrix.triple.target == 'i686-unknown-linux-musl' + run: | + sudo dpkg --add-architecture i386 + sudo apt update + sudo apt install gcc-multilib -y + - uses: Swatinem/rust-cache@v1 with: key: ${{ matrix.triple.target }} From 31072d19527bdd8e85fdabe83bc81bf2cfe9919f Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Sun, 3 Oct 2021 17:13:14 -0400 Subject: [PATCH 04/13] ci: revert previous i686 change (#593) Reverts #592, this was done incorrectly, I changed the wrong thing and I also didn't need to change said thing. --- .github/workflows/nightly.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c94bbf9b..2b07acc7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -68,7 +68,7 @@ jobs: - { os: "ubuntu-18.04", target: "i686-unknown-linux-gnu", - cross: false, + cross: true, strip: true, } - { @@ -143,13 +143,6 @@ jobs: override: true target: ${{ matrix.triple.target }} - - name: Install gcc-multilib for (Linux i686) - if: matrix.triple.target == 'i686-unknown-linux-gnu' || matrix.triple.target == 'i686-unknown-linux-musl' - run: | - sudo dpkg --add-architecture i386 - sudo apt update - sudo apt install gcc-multilib -y - - uses: Swatinem/rust-cache@v1 with: key: ${{ matrix.triple.target }} From a1a33e012012425a46a5372f2c2d275062c70735 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Sun, 3 Oct 2021 17:49:29 -0400 Subject: [PATCH 05/13] ci: parallelize ci better (#594) Parallelizes the CI workflow better. --- .github/workflows/ci.yml | 142 +++++++++++++++++++++++++++++---------- 1 file changed, 108 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c12e669..20325c8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,7 +69,7 @@ jobs: - run: cargo clippy --all-targets --workspace -- -D warnings - # Compile/check/test. + # Run cargo --check on all platforms check: needs: [rustfmt, clippy] runs-on: ${{ matrix.triple.os }} @@ -78,13 +78,12 @@ jobs: fail-fast: false matrix: triple: - # Standard x86-64 stuff, stable + # x86 or x64 - { os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu", cross: false, rust: stable, - toTest: "true", } - { os: "ubuntu-latest", @@ -92,51 +91,42 @@ jobs: cross: true, rust: stable, } - # - { - # os: "ubuntu-latest", - # target: "x86_64-unknown-linux-musl", - # cross: false, - # rust: stable, - # } - # - { - # os: "ubuntu-latest", - # target: "i686-unknown-linux-musl", - # cross: true, - # rust: stable, - # } + - { + os: "ubuntu-latest", + target: "x86_64-unknown-linux-musl", + cross: false, + rust: stable, + } + - { + os: "ubuntu-latest", + target: "i686-unknown-linux-musl", + cross: true, + rust: stable, + } - { os: "macOS-latest", target: "x86_64-apple-darwin", cross: false, rust: stable, - toTest: "true", } - # Big Sur builds are disabled, unfortunately. - # - { - # os: "macOS-11.0", - # target: "x86_64-apple-darwin", - # cross: false, - # rust: stable, - # } - { os: "windows-2019", target: "x86_64-pc-windows-msvc", cross: false, rust: stable, - toTest: "true", } - { os: "windows-2019", target: "i686-pc-windows-msvc", - cross: true, + cross: false, + rust: stable, + } + - { + os: "windows-2019", + target: "x86_64-pc-windows-gnu", + cross: false, rust: stable, } - # - { - # os: "windows-2019", - # target: "x86_64-pc-windows-gnu", - # cross: false, - # rust: stable, - # } # aarch64 - { @@ -208,16 +198,100 @@ jobs: args: --all-targets --verbose --target=${{ matrix.triple.target }} --features "battery" use-cross: ${{ matrix.triple.cross }} + # Check without the battery feature enabled on x86-64 for supported operating systems + check-without-battery: + needs: [rustfmt, clippy] + runs-on: ${{ matrix.triple.os }} + continue-on-error: true + strategy: + fail-fast: false + matrix: + triple: + - { + os: "ubuntu-latest", + target: "x86_64-unknown-linux-gnu", + cross: false, + rust: stable, + } + - { + os: "macOS-latest", + target: "x86_64-apple-darwin", + cross: false, + rust: stable, + } + - { + os: "windows-2019", + target: "x86_64-pc-windows-msvc", + cross: false, + rust: stable, + } + + steps: + - uses: actions/checkout@v2 + + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.triple.rust }} + override: true + target: ${{ matrix.triple.target }} + + - uses: Swatinem/rust-cache@v1 + with: + key: ${{ matrix.triple.target }} + - name: Check without battery feature on the main 3 - if: matrix.triple.toTest == 'true' uses: actions-rs/cargo@v1 with: command: check - args: --all-targets --verbose --target=${{ matrix.triple.target }} + args: --all-targets --verbose --target=${{ matrix.triple.target }} --no-default-features use-cross: ${{ matrix.triple.cross }} + # Run tests x86-64 for supported operating systems + test: + needs: [rustfmt, clippy] + runs-on: ${{ matrix.triple.os }} + continue-on-error: true + strategy: + fail-fast: false + matrix: + triple: + - { + os: "ubuntu-latest", + target: "x86_64-unknown-linux-gnu", + cross: false, + rust: stable, + } + - { + os: "macOS-latest", + target: "x86_64-apple-darwin", + cross: false, + rust: stable, + } + - { + os: "windows-2019", + target: "x86_64-pc-windows-msvc", + cross: false, + rust: stable, + } + + steps: + - uses: actions/checkout@v2 + + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.triple.rust }} + override: true + target: ${{ matrix.triple.target }} + + - uses: Swatinem/rust-cache@v1 + with: + key: ${{ matrix.triple.target }} + - name: Run tests - if: matrix.triple.toTest == 'true' run: cargo test --no-fail-fast env: CARGO_HUSKY_DONT_INSTALL_HOOKS: true From a362b6c9dd1d7b30513add75d94f218df9200fa9 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Sat, 9 Oct 2021 02:29:17 -0400 Subject: [PATCH 06/13] ci: Create release only if the entire pipeline passes (#595) In a similar vein to #590, we only create a release after the entire pipeline is completed and succeeds. Also fixes some incorrect job names and adds some "/'s" after directory names in the nightly pipeline. --- .github/workflows/deployment.yml | 290 +++++++++++++++---------------- .github/workflows/nightly.yml | 18 +- 2 files changed, 148 insertions(+), 160 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 70fd7d5a..2c7ea041 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -15,13 +15,10 @@ on: - "[0-9]+.[0-9]+.[0-9]+" jobs: - create-github-release: - name: create-github-release + initialize-release-job: + name: initialize-release-job runs-on: ubuntu-latest steps: - - name: Create artifacts directory - run: mkdir artifacts - - name: Get the release version from the tag if: env.VERSION == '' run: | @@ -36,31 +33,19 @@ jobs: run: | echo "Version being built against is version ${{ env.VERSION }}"! - - name: Create GitHub release - id: release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - draft: true - tag_name: ${{ env.VERSION }} - release_name: ${{ env.VERSION }} Release - - - name: Save release upload URL to artifact - run: echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url - - name: Save version number to artifact - run: echo "${{ env.VERSION }}" > artifacts/release-version + run: echo "${{ env.VERSION }}" > release-version - - name: Upload artifacts - uses: actions/upload-artifact@v1 + - name: Upload release-version as artifact + uses: actions/upload-artifact@v2 with: - name: artifacts - path: artifacts + retention-days: 3 + name: release-version + path: release-version build-release: name: build-release - needs: [create-github-release] + needs: [initialize-release-job] runs-on: ${{ matrix.triple.os }} container: ${{ matrix.triple.container }} env: @@ -74,7 +59,6 @@ jobs: os: "ubuntu-18.04", target: "x86_64-unknown-linux-gnu", cross: false, - artifact: true, strip: true, } - { @@ -95,7 +79,6 @@ jobs: os: "ubuntu-18.04", target: "x86_64-unknown-linux-musl", cross: false, - artifact: true, strip: true, } - { @@ -108,21 +91,14 @@ jobs: os: "macOS-latest", target: "x86_64-apple-darwin", cross: false, - artifact: true, strip: true, } - { os: "windows-2019", target: "x86_64-pc-windows-msvc", cross: false, - artifact: true, - } - - { - os: "windows-2019", - target: "i686-pc-windows-msvc", - cross: false, - artifact: true, } + - { os: "windows-2019", target: "i686-pc-windows-msvc", cross: false } - { os: "windows-2019", target: "x86_64-pc-windows-gnu", @@ -134,7 +110,6 @@ jobs: os: "ubuntu-18.04", target: "aarch64-unknown-linux-gnu", cross: true, - artifact: true, } # armv7 @@ -142,7 +117,6 @@ jobs: os: "ubuntu-18.04", target: "armv7-unknown-linux-gnueabihf", cross: true, - artifact: true, } # PowerPC 64 LE @@ -165,25 +139,6 @@ jobs: with: fetch-depth: 1 - - name: Get release download URL - uses: actions/download-artifact@v2 - with: - name: artifacts - path: artifacts - - - name: Set release upload URL and release version - shell: bash - run: | - release_upload_url="$(cat ./artifacts/release-upload-url)" - echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV - release_version="$(cat ./artifacts/release-version)" - echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - - - name: Validate release environment variables - run: | - echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}" - echo "Release version: ${{ env.RELEASE_VERSION }}" - - name: Install toolchain uses: actions-rs/toolchain@v1 with: @@ -233,47 +188,29 @@ jobs: tar -czvf bottom_${{ matrix.triple.target }}${{ matrix.triple.suffix }}.tar.gz btm completion echo "ASSET=bottom_${{ matrix.triple.target }}${{ matrix.triple.suffix }}.tar.gz" >> $GITHUB_ENV - - name: Upload main release - uses: actions/upload-release-asset@v1.0.1 - id: upload - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ env.RELEASE_UPLOAD_URL }} - asset_path: ${{ env.ASSET }} - asset_name: ${{ env.ASSET }} - asset_content_type: application/octet-stream - - - name: Add download asset to artifact if required - if: matrix.triple.artifact == true - run: cp ${{ env.ASSET }} artifacts/ - - - name: Upload artifacts - uses: actions/upload-artifact@v1 - with: - name: artifacts - path: artifacts + - name: Create release directory for artifact, move file + shell: bash + run: | + mkdir release + mv ${{ env.ASSET }} release/ - name: Compress completion files (Linux x86-64 GNU) if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' shell: bash run: | tar -C ./completion -czvf completion.tar.gz . + mv completion.tar.gz release/ - - name: Release completion files (Linux x86-64 GNU) - if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Save release as artifact + uses: actions/upload-artifact@v2 with: - upload_url: ${{ env.RELEASE_UPLOAD_URL }} - asset_path: completion.tar.gz - asset_name: completion.tar.gz - asset_content_type: application/octet-stream + retention-days: 3 + name: release + path: release build-msi: name: build-msi - needs: [create-github-release] + needs: [initialize-release-job] runs-on: "windows-2019" env: RUST_BACKTRACE: 1 @@ -285,23 +222,20 @@ jobs: - uses: actions/setup-python@v2 - - name: Get release download URL + - name: Get release version uses: actions/download-artifact@v2 with: - name: artifacts - path: artifacts + name: release-version + path: release-version - - name: Set release upload URL and release version + - name: Set release version shell: bash run: | - release_upload_url="$(cat ./artifacts/release-upload-url)" - echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV - release_version="$(cat ./artifacts/release-version)" + release_version="$(cat ./release-version/release-version)" echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - - name: Validate release environment variables + - name: Validate release version run: | - echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}" echo "Release version: ${{ env.RELEASE_VERSION }}" - name: Install Net-Framework-Core (Windows x86-64 MSVC) @@ -332,35 +266,29 @@ jobs: cargo wix init cargo wix - - name: Upload msi file - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ env.RELEASE_UPLOAD_URL }} - asset_path: bottom_x86_64_installer.msi - asset_name: bottom_x86_64_installer.msi - asset_content_type: application/octet-stream - - name: Build winget run: | python "./deployment/packager.py" ${{ env.RELEASE_VERSION }} "./deployment/windows/winget/winget.yaml.template" "Clement.bottom.yaml" "SHA256" "./bottom_x86_64_installer.msi" $Code = powershell ./deployment/windows/winget/get_product_code.ps1 ./bottom_x86_64_installer.msi python "./deployment/windows/winget/product_code.py" Clement.bottom.yaml $Code - - name: Upload winget file - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create release directory for artifact, move files + shell: bash + run: | + mkdir release + mv bottom_x86_64_installer.msi release/ + mv Clement.bottom.yaml release/ + + - name: Save release as artifact + uses: actions/upload-artifact@v2 with: - upload_url: ${{ env.RELEASE_UPLOAD_URL }} - asset_path: Clement.bottom.yaml - asset_name: Clement.bottom.yaml - asset_content_type: application/octet-stream + retention-days: 3 + name: release + path: release build-deb: name: build-deb - needs: [create-github-release] + needs: [initialize-release-job] runs-on: "ubuntu-18.04" env: RUST_BACKTRACE: 1 @@ -370,23 +298,20 @@ jobs: with: fetch-depth: 1 - - name: Get release download URL + - name: Get release version uses: actions/download-artifact@v2 with: - name: artifacts - path: artifacts + name: release-version + path: release-version - - name: Set release upload URL and release version + - name: Set release version shell: bash run: | - release_upload_url="$(cat ./artifacts/release-upload-url)" - echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV - release_version="$(cat ./artifacts/release-version)" + release_version="$(cat ./release-version/release-version)" echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - - name: Validate release environment variables + - name: Validate release version run: | - echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}" echo "Release version: ${{ env.RELEASE_VERSION }}" - name: Install toolchain @@ -407,19 +332,22 @@ jobs: cargo deb cp ./target/debian/bottom_*.deb ./bottom_${{ env.RELEASE_VERSION }}_amd64.deb - - name: Upload Debian file (Linux x86-64 GNU) - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ env.RELEASE_UPLOAD_URL }} - asset_path: bottom_${{ env.RELEASE_VERSION }}_amd64.deb - asset_name: bottom_${{ env.RELEASE_VERSION }}_amd64.deb - asset_content_type: application/octet-stream + - name: Create release directory for artifact, move file + shell: bash + run: | + mkdir release + mv bottom_${{ env.RELEASE_VERSION }}_amd64.deb release/ - additional-file-generation: + - name: Save release as artifact + uses: actions/upload-artifact@v2 + with: + retention-days: 3 + name: release + path: release + + generate-choco: needs: [build-release] - name: additional-file-generation + name: generate-choco runs-on: ubuntu-latest steps: - name: Checkout repository @@ -429,36 +357,96 @@ jobs: - uses: actions/setup-python@v2 - - name: Get release download URL + - name: Get release version uses: actions/download-artifact@v2 with: - name: artifacts - path: artifacts + name: release-version + path: release-version - - name: Set release upload URL, download URL and version + - name: Set release version shell: bash run: | - release_upload_url="$(cat ./artifacts/release-upload-url)" - echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV - release_version="$(cat ./artifacts/release-version)" + release_version="$(cat ./release-version/release-version)" echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - - name: Validate release environment variables + - name: Validate release version run: | - echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}" echo "Release version: ${{ env.RELEASE_VERSION }}" + - name: Get release artifacts + uses: actions/download-artifact@v2 + with: + name: release + path: release + - name: Execute choco packaging script run: | - python "./deployment/windows/choco/choco_packager.py" "./artifacts/bottom_i686-pc-windows-msvc.zip" "./artifacts/bottom_x86_64-pc-windows-msvc.zip" ${{ env.RELEASE_VERSION }} "./deployment/windows/choco/bottom.nuspec.template" "./deployment/windows/choco/chocolatey_install.ps1.template" "bottom.nuspec" "tools/chocolatey_install.ps1" "tools/" + python "./deployment/windows/choco/choco_packager.py" "./release/bottom_i686-pc-windows-msvc.zip" "./release/bottom_x86_64-pc-windows-msvc.zip" ${{ env.RELEASE_VERSION }} "./deployment/windows/choco/bottom.nuspec.template" "./deployment/windows/choco/chocolatey_install.ps1.template" "bottom.nuspec" "tools/chocolatey_install.ps1" "tools/" zip -r choco.zip "bottom.nuspec" "tools" - - name: Upload choco.zip to release - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Move release file into release directory + shell: bash + run: | + mv choco.zip release/ + + - name: Save release as artifact + uses: actions/upload-artifact@v2 with: - upload_url: ${{ env.RELEASE_UPLOAD_URL }} - asset_path: choco.zip - asset_name: choco.zip - asset_content_type: application/octet-stream + retention-days: 3 + name: release + path: release + + upload-release: + name: upload-release + runs-on: ubuntu-latest + needs: [generate-choco, build-deb, build-msi] + steps: + - name: Get release version + uses: actions/download-artifact@v2 + with: + name: release-version + path: release-version + + - name: Set release version + shell: bash + run: | + release_version="$(cat ./release-version/release-version)" + echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV + + - name: Validate release version + run: | + echo "Release version: ${{ env.RELEASE_VERSION }}" + + - name: Get release artifacts + uses: actions/download-artifact@v2 + with: + name: release + path: release + + - name: Print out all release files + run: | + echo "Generated $(ls ./release | wc -l) files:" + ls ./release + + - name: Upload all saved release files + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + prerelease: false + tag_name: ${{ env.RELEASE_VERSION }} + draft: true + fail_on_unmatched_files: true + name: ${{ env.RELEASE_VERSION }} Release + body: | + + --- + + ## Features + + ## Changes + + ## Bug Fixes + + ## Internal Changes + files: | + ./release/* diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2b07acc7..c1f7f8da 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -188,14 +188,14 @@ jobs: shell: bash run: | mkdir release - mv ${{ env.ASSET }} release + mv ${{ env.ASSET }} release/ - name: Compress completion files (Linux x86-64 GNU) if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' shell: bash run: | tar -C ./completion -czvf completion.tar.gz . - mv completion.tar.gz release + mv completion.tar.gz release/ - name: Save release files as artifacts uses: actions/upload-artifact@v2 @@ -216,7 +216,7 @@ jobs: with: fetch-depth: 1 - - name: Get release download URL + - name: Get release version uses: actions/download-artifact@v2 with: name: release-version @@ -228,7 +228,7 @@ jobs: release_version="$(cat ./release-version/release-version)" echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - - name: Validate release environment variables + - name: Validate release version run: | echo "Release version: ${{ env.RELEASE_VERSION }}" @@ -264,7 +264,7 @@ jobs: shell: bash run: | mkdir release - mv bottom_x86_64_installer.msi release + mv bottom_x86_64_installer.msi release/ - name: Save msi file as artifacts uses: actions/upload-artifact@v2 @@ -285,19 +285,19 @@ jobs: with: fetch-depth: 1 - - name: Get release download URL + - name: Get release version uses: actions/download-artifact@v2 with: name: release-version path: release-version - - name: Set release upload URL and release version + - name: Set release version shell: bash run: | release_version="$(cat ./release-version/release-version)" echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - - name: Validate release environment variables + - name: Validate release version run: | echo "Release version: ${{ env.RELEASE_VERSION }}" @@ -323,7 +323,7 @@ jobs: shell: bash run: | mkdir release - mv bottom_${{ env.RELEASE_VERSION }}_amd64.deb release + mv bottom_${{ env.RELEASE_VERSION }}_amd64.deb release/ - name: Save Debian file as artifacts uses: actions/upload-artifact@v2 From 65d3dd7af52d715a3fa4a411de3ac7770124af5f Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Sun, 10 Oct 2021 18:16:21 -0400 Subject: [PATCH 07/13] ci: simplify python dependency step for release/doc pipeline (#596) Slightly simplifies the whole Python dependency step for pipelines generating mkdocs. --- .github/workflows/docs.yml | 15 ++++++--------- .github/workflows/post-release.yml | 17 ++++------------- docs/requirements.txt | 3 +++ 3 files changed, 13 insertions(+), 22 deletions(-) create mode 100644 docs/requirements.txt diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index eeaaf405..6f8175fd 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -5,13 +5,13 @@ on: branches: - master paths: - - 'docs/**' - - '.github/workflows/docs.yml' + - "docs/**" + - ".github/workflows/docs.yml" env: # Assign commit authorship to official Github Actions bot when pushing to the `gh-pages` branch: - GIT_USER: 'github-actions[bot]' - GIT_EMAIL: '41898282+github-actions[bot]@users.noreply.github.com' + GIT_USER: "github-actions[bot]" + GIT_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com" jobs: build-documentation: @@ -26,11 +26,8 @@ jobs: with: python-version: 3.x - - run: pip install mkdocs-material==7.2.6 - - - run: pip install mdx_truly_sane_lists==1.2 - - - run: pip install mike==1.1.0 + - name: Install Python dependencies + run: pip install docs/requirements.txt - name: Configure git user and email run: | diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index 1cd7e728..c835a2eb 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -27,15 +27,9 @@ jobs: run: | echo $RELEASE_VERSION - - name: Make sure you're not on master... + - name: Make sure you're not on master/main/nightly... run: | - if [[ $RELEASE_VERSION == "master" ]]; then - exit 1 - fi - - - name: Make sure you're not on nightly... - run: | - if [[ $RELEASE_VERSION == "nightly" ]]; then + if [[ $RELEASE_VERSION == "master" || $RELEASE_VERSION == "main" || $RELEASE_VERSION == "nightly" ]]; then exit 1 fi @@ -43,11 +37,8 @@ jobs: with: python-version: 3.x - - run: pip install mkdocs-material==7.2.6 - - - run: pip install mdx_truly_sane_lists==1.2 - - - run: pip install mike==1.1.0 + - name: Install Python dependencies + run: pip install docs/requirements.txt - name: Configure git user and email run: | diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 00000000..b29234b0 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,3 @@ +mkdocs-material == 7.3.2 +mdx_truly_sane_lists == 1.2 +mike == 1.1.2 \ No newline at end of file From 4b705572c6ce42b693f4236193eba8190d7fcd5d Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Sun, 10 Oct 2021 18:17:20 -0400 Subject: [PATCH 08/13] ci: forgot a -r --- .github/workflows/docs.yml | 2 +- .github/workflows/post-release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 6f8175fd..b8fd4980 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -27,7 +27,7 @@ jobs: python-version: 3.x - name: Install Python dependencies - run: pip install docs/requirements.txt + run: pip install -r docs/requirements.txt - name: Configure git user and email run: | diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index c835a2eb..1cf2b907 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -38,7 +38,7 @@ jobs: python-version: 3.x - name: Install Python dependencies - run: pip install docs/requirements.txt + run: pip install -r docs/requirements.txt - name: Configure git user and email run: | From 6c157fe1ddde267a44d2bd0577291e39435c31bd Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Sun, 17 Oct 2021 21:32:08 -0400 Subject: [PATCH 09/13] ci: allow manual triggering of audit action --- .github/workflows/audit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index fa597646..1a017bfb 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -1,5 +1,6 @@ name: audit on: + workflow_dispatch: schedule: - cron: "0 0 * * 1" jobs: From ea0c7b49b7f4f546f4c20997b6efeea253c8d078 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Sun, 17 Oct 2021 21:33:07 -0400 Subject: [PATCH 10/13] deps: bump deps, remove chrono (#600) Bumps up some dependencies and removes chrono, switching to the time crate instead. One of side-effects of this change is that local time seems to not work (?)... so all logs are now in UTC. Oh well, this doesn't affect general user behaviour so I'm fine with it. --- Cargo.lock | 146 +++++++++++----------- Cargo.toml | 4 +- src/app/data_harvester/processes/linux.rs | 2 +- src/data_conversion.rs | 20 +-- src/utils/logging.rs | 10 +- 5 files changed, 94 insertions(+), 88 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 483bd009..a72008fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,7 +49,7 @@ checksum = "c98233c6673d8601ab23e77eb38f999c51100d46c5703b17288c57fddf3a1ffe" dependencies = [ "bstr", "doc-comment", - "predicates 2.0.2", + "predicates 2.0.3", "predicates-core", "predicates-tree", "wait-timeout", @@ -210,9 +210,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "blocking" @@ -238,7 +238,6 @@ dependencies = [ "battery", "cargo-husky", "cfg-if", - "chrono", "clap", "crossterm", "ctrlc", @@ -260,6 +259,7 @@ dependencies = [ "smol", "sysinfo", "thiserror", + "time", "toml", "tui", "typed-builder", @@ -270,9 +270,9 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ "lazy_static", "memchr", @@ -305,9 +305,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] name = "cc" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" +checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" [[package]] name = "cfg-if" @@ -315,19 +315,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "libc", - "num-integer", - "num-traits", - "time", - "winapi", -] - [[package]] name = "clap" version = "2.33.3" @@ -364,11 +351,11 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" dependencies = [ - "core-foundation-sys 0.8.2", + "core-foundation-sys 0.8.3", "libc", ] @@ -380,9 +367,9 @@ checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" [[package]] name = "core-foundation-sys" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "crc32fast" @@ -464,11 +451,11 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.2.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "377c9b002a72a0b2c1a18c62e2f3864bdfea4a015e3683a96e24aa45dd6c02d1" +checksum = "a19c6cedffdc8c03a3346d723eb20bd85a13362bb96dc2ac000842c6381ec7bf" dependencies = [ - "nix 0.22.1", + "nix 0.23.0", "winapi", ] @@ -736,7 +723,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d767e6e47cf88abe7c9a5ebb4df82f180d30d9c0ba0269b6d166482461765834" dependencies = [ "cfg-if", - "core-foundation 0.9.1", + "core-foundation 0.9.2", "futures-core", "futures-util", "lazy_static", @@ -775,7 +762,7 @@ checksum = "75603ff3868851c04954ee86bf610a6bd45be2732a0e81c35fd72b2b90fa4718" dependencies = [ "bitflags", "cfg-if", - "core-foundation 0.9.1", + "core-foundation 0.9.2", "heim-common", "heim-runtime", "libc", @@ -864,9 +851,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" +checksum = "716d3d89f35ac6a34fd0eed635395f4c3b76fa889338a4632e5231a8684216bd" dependencies = [ "cfg-if", ] @@ -880,6 +867,12 @@ dependencies = [ "either", ] +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + [[package]] name = "lazy_static" version = "1.4.0" @@ -894,9 +887,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.102" +version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103" +checksum = "7b2f96d100e1cf1929e7719b7edb3b90ab5298072638fccd77be9ce942ecdfce" [[package]] name = "lock_api" @@ -958,9 +951,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" +checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" dependencies = [ "libc", "log", @@ -992,9 +985,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.22.1" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7555d6c7164cc913be1ce7f95cbecdabda61eb2ccd89008524af306fb7f5031" +checksum = "f305c2c2e4c39a82f7bf0bf65fb557f9070ce06781d4f2454295cc34b1c43188" dependencies = [ "bitflags", "cc", @@ -1144,9 +1137,9 @@ dependencies = [ [[package]] name = "predicates" -version = "2.0.2" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c143348f141cc87aab5b950021bac6145d0e5ae754b0591de23244cee42c9308" +checksum = "5c6ce811d0b2e103743eec01db1c50612221f173084ce2f7941053e94b6bb474" dependencies = [ "difflib", "itertools", @@ -1161,12 +1154,12 @@ checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" [[package]] name = "predicates-tree" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7dd0fd014130206c9352efbdc92be592751b2b9274dff685348341082c6ea3d" +checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7" dependencies = [ "predicates-core", - "treeline", + "termtree", ] [[package]] @@ -1183,22 +1176,21 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" +checksum = "edc3358ebc67bc8b7fa0c007f945b0b18226f78437d61bec735a9eb96b61ee70" dependencies = [ "unicode-xid", ] [[package]] name = "procfs" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95e344cafeaeefe487300c361654bcfc85db3ac53619eeccced29f5ea18c4c70" +checksum = "3f2e7eea7c1d7beccbd5acc1e37ac844afccf176525674aad26ece3de1fc7733" dependencies = [ "bitflags", "byteorder", - "chrono", "flate2", "hex", "lazy_static", @@ -1207,9 +1199,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" dependencies = [ "proc-macro2", ] @@ -1345,15 +1337,15 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" [[package]] name = "smallvec" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" [[package]] name = "smol" @@ -1391,9 +1383,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" -version = "1.0.76" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84" +checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" dependencies = [ "proc-macro2", "quote", @@ -1407,7 +1399,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d404aefa651a24a7f2a1190fec9fb6380ba84ac511a6fefad79eb0e63d39a97d" dependencies = [ "cfg-if", - "core-foundation-sys 0.8.2", + "core-foundation-sys 0.8.3", "doc-comment", "libc", "ntapi", @@ -1416,6 +1408,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "termtree" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78fbf2dd23e79c28ccfa2472d3e6b3b189866ffef1aeb91f17c2d968b6586378" + [[package]] name = "textwrap" version = "0.11.0" @@ -1427,18 +1425,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", @@ -1447,15 +1445,21 @@ dependencies = [ [[package]] name = "time" -version = "0.1.44" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "cde1cf55178e0293453ba2cca0d5f8392a922e52aa958aee9c28ed02becc6d03" dependencies = [ + "itoa", "libc", - "wasi", - "winapi", + "time-macros", ] +[[package]] +name = "time-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25eb0ca3468fc0acc11828786797f6ef9aa1555e4a211a60d64cc8e4d1be47d6" + [[package]] name = "toml" version = "0.5.8" @@ -1465,12 +1469,6 @@ dependencies = [ "serde", ] -[[package]] -name = "treeline" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" - [[package]] name = "tui" version = "0.14.0" @@ -1553,9 +1551,9 @@ checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wepoll-ffi" diff --git a/Cargo.toml b/Cargo.toml index 05f24aa3..8d244573 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,6 @@ default = ["fern", "log", "battery"] [dependencies] anyhow = "1.0.40" backtrace = "0.3.59" -chrono = "0.4.19" crossterm = "0.18.2" ctrlc = { version = "3.1.9", features = ["termination"] } clap = "2.33" @@ -53,6 +52,7 @@ serde = { version = "1.0.125", features = ["derive"] } # Sysinfo is still used in Linux for the ProcessStatus sysinfo = "0.18.2" thiserror = "1.0.24" +time = { version = "0.3.3", features = ["formatting", "local-offset", "macros"] } toml = "0.5.8" tui = { version = "0.14.0", features = ["crossterm"], default-features = false } typed-builder = "0.9.0" @@ -69,7 +69,7 @@ libc = "0.2.86" [target.'cfg(target_os = "linux")'.dependencies] heim = { version = "0.1.0-rc.1", features = ["cpu", "disk", "net", "sensors"] } -procfs = "0.10.1" +procfs = { version = "0.11.0", default-features = false } smol = "1.2.5" [target.'cfg(target_os = "macos")'.dependencies] diff --git a/src/app/data_harvester/processes/linux.rs b/src/app/data_harvester/processes/linux.rs index 87297837..d7d621dc 100644 --- a/src/app/data_harvester/processes/linux.rs +++ b/src/app/data_harvester/processes/linux.rs @@ -162,7 +162,7 @@ fn read_proc( use_current_cpu_total, ); let parent_pid = Some(stat.ppid); - let mem_usage_bytes = u64::try_from(stat.rss_bytes()).unwrap_or(0); + let mem_usage_bytes = u64::try_from(stat.rss_bytes()?).unwrap_or(0); let mem_usage_kb = mem_usage_bytes / 1024; let mem_usage_percent = mem_usage_kb as f64 / mem_total_kb as f64 * 100.0; diff --git a/src/data_conversion.rs b/src/data_conversion.rs index 7e4d214e..5aaa9f31 100644 --- a/src/data_conversion.rs +++ b/src/data_conversion.rs @@ -1375,13 +1375,13 @@ pub fn convert_battery_harvest( charge_percentage: battery_harvest.charge_percent, watt_consumption: format!("{:.2}W", battery_harvest.power_consumption_rate_watts), duration_until_empty: if let Some(secs_till_empty) = battery_harvest.secs_until_empty { - let time = chrono::Duration::seconds(secs_till_empty); - let num_minutes = time.num_minutes() - time.num_hours() * 60; - let num_seconds = time.num_seconds() - time.num_minutes() * 60; + let time = time::Duration::seconds(secs_till_empty); + let num_minutes = time.whole_minutes() - time.whole_hours() * 60; + let num_seconds = time.whole_seconds() - time.whole_minutes() * 60; Some(format!( "{} hour{}, {} minute{}, {} second{}", - time.num_hours(), - if time.num_hours() == 1 { "" } else { "s" }, + time.whole_hours(), + if time.whole_hours() == 1 { "" } else { "s" }, num_minutes, if num_minutes == 1 { "" } else { "s" }, num_seconds, @@ -1391,13 +1391,13 @@ pub fn convert_battery_harvest( None }, duration_until_full: if let Some(secs_till_full) = battery_harvest.secs_until_full { - let time = chrono::Duration::seconds(secs_till_full); // FIXME [DEP]: Can I get rid of chrono? - let num_minutes = time.num_minutes() - time.num_hours() * 60; - let num_seconds = time.num_seconds() - time.num_minutes() * 60; + let time = time::Duration::seconds(secs_till_full); + let num_minutes = time.whole_minutes() - time.whole_hours() * 60; + let num_seconds = time.whole_seconds() - time.whole_minutes() * 60; Some(format!( "{} hour{}, {} minute{}, {} second{}", - time.num_hours(), - if time.num_hours() == 1 { "" } else { "s" }, + time.whole_hours(), + if time.whole_hours() == 1 { "" } else { "s" }, num_minutes, if num_minutes == 1 { "" } else { "s" }, num_seconds, diff --git a/src/utils/logging.rs b/src/utils/logging.rs index 704f6434..2e021588 100644 --- a/src/utils/logging.rs +++ b/src/utils/logging.rs @@ -4,9 +4,17 @@ pub fn init_logger( ) -> Result<(), fern::InitError> { fern::Dispatch::new() .format(|out, message, record| { + let offset = time::OffsetDateTime::now_utc(); + out.finish(format_args!( "{}[{}][{}] {}", - chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S:%f]"), + offset + .format(&time::macros::format_description!( + // The weird "[[[" is because we need to escape a bracket ("[[") to show one "[". + // See https://time-rs.github.io/book/api/format-description.html + "[[[year]-[month]-[day]][[[hour]:[minute]:[second][subsecond digits:9]]" + )) + .unwrap(), record.target(), record.level(), message From a9b808334c9f42c0f9f2d2548d7ec6c6de9a0c5a Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Sun, 17 Oct 2021 21:44:19 -0400 Subject: [PATCH 11/13] docs: tweak wording in README and CONTRIBUTING --- CONTRIBUTING.md | 13 +++++++------ README.md | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4c679913..e021c870 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,14 +15,15 @@ Please use the [feature request template](https://github.com/ClementTsang/bottom ## Pull requests -The expected workflow for a pull request is: +If you want to directly contribute documentation changes or code, follow this! The expected workflow for a pull request is: 1. Fork the project. -2. Make your changes. -3. Make any documentation changes if necessary - if you add a new feature, it'll probably need documentation changes. See [here](./documentation.md) for tips on documentation. -4. Commit and create a pull request to merge into the `master` branch. **Please follow the pull request template**. -5. Wait for the tests to pass. These consist of clippy lints, rustfmt checks, and basic tests. **If you are a first time contributor, you may need to skip this step for now, as GitHub Actions requires approval to run.** -6. Ask a maintainer to review your pull request. If changes are suggested or any comments are made, they should probably be addressed. Once it looks good, it'll be merged! +2. Make your changes locally. + - If you're making a documentation change, you may want to read [this page](https://clementtsang.github.io/bottom/nightly/contribution/documentation/), especially if you're touching mkdocs pages. + - If you add a new feature, it'll probably also need documentation changes - again, see [this page](https://clementtsang.github.io/bottom/nightly/contribution/documentation/). +3. Commit and create a pull request to merge into the `master` branch. **Please follow the pull request template**. +4. Wait for the tests to pass. These consist of clippy lints, rustfmt checks, and basic tests. **If you are a first time contributor, skip to the next step for now, as GitHub Actions requires approval to run.** +5. Ask a maintainer to review your pull request. If changes are suggested or any comments are made, they should probably be addressed. Once it looks good, it'll be merged! ## Further reading diff --git a/README.md b/README.md index 4b89f07a..feed9943 100644 --- a/README.md +++ b/README.md @@ -244,12 +244,13 @@ More details on configuration can be found [in the documentation](https://clemen ## Contribution -Whether it's reporting problems, documentation, or code, contribution is always welcome! Please read -[CONTRIBUTING.md](./CONTRIBUTING.md) for details on how to contribute to bottom. +Whether it's reporting bugs, suggesting features, maintaining packages, or submitting a PR, +contribution is always welcome! Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for details on how to +contribute to bottom. ### Contributors -Thanks to all contributors ([emoji key](https://allcontributors.org/docs/en/emoji-key)): +Thanks to all contributors: From 4b49ddabe5f9021b81430ec15a6d4939de9b3b9d Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Sun, 17 Oct 2021 21:54:06 -0400 Subject: [PATCH 12/13] ci: add some documentation in the workflow files --- .github/workflows/audit.yml | 2 ++ .github/workflows/post-release.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 1a017bfb..6189d737 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -1,3 +1,5 @@ +# A routine check to see if there are any Rust-specific security vulnerabilities in the repo we should be aware of. + name: audit on: workflow_dispatch: diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index 1cf2b907..5eed7cc4 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -1,4 +1,4 @@ -# Actions to run after releasing a version. +# Actions to run after releasing a version, like generating documentation via mkdocs or notifying packaging repos. name: post-release on: From 77ada576c548614cca35feae0af950fd423be78c Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Tue, 19 Oct 2021 18:29:59 -0400 Subject: [PATCH 13/13] docs: more contribution doc stuff --- CONTRIBUTING.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e021c870..8a470ff2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,13 +19,17 @@ If you want to directly contribute documentation changes or code, follow this! T 1. Fork the project. 2. Make your changes locally. - - If you're making a documentation change, you may want to read [this page](https://clementtsang.github.io/bottom/nightly/contribution/documentation/), especially if you're touching mkdocs pages. - - If you add a new feature, it'll probably also need documentation changes - again, see [this page](https://clementtsang.github.io/bottom/nightly/contribution/documentation/). 3. Commit and create a pull request to merge into the `master` branch. **Please follow the pull request template**. 4. Wait for the tests to pass. These consist of clippy lints, rustfmt checks, and basic tests. **If you are a first time contributor, skip to the next step for now, as GitHub Actions requires approval to run.** 5. Ask a maintainer to review your pull request. If changes are suggested or any comments are made, they should probably be addressed. Once it looks good, it'll be merged! -## Further reading +For more details, see [here](https://clementtsang.github.io/bottom/nightly/contribution/issues-and-pull-requests/). -- For details on contributing to documentation, see [here](https://clementtsang.github.io/bottom/nightly/contribution/documentation/). -- For details on packaging and distribution, see [here](https://clementtsang.github.io/bottom/nightly/contribution/packaging-and-distribution/). +### Documentation + +For contributing to documentation, see [here](https://clementtsang.github.io/bottom/nightly/contribution/documentation/). + +### Packaging + +If you want to become a package maintainer, look [here](https://clementtsang.github.io/bottom/nightly/contribution/packaging-and-distribution/) +for instructions on how to build bottom and add installation instructions to the README.