From 57eba21162835610e2b09681a295ecd8ffd295d7 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Fri, 23 Feb 2024 07:52:27 +0000 Subject: [PATCH 01/42] =?UTF-8?q?=F0=9F=93=9D=20Add=20issue=20template=20c?= =?UTF-8?q?onfiguration=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/config.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..0fc7a05 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: true +contact_links: + - name: Ask a question on how to use template-exercisme + about: For general-purpose questions and answers, see the Discussions section. + url: https://github.com/MathieuSoysal/Exercism-Rust-Template/discussions \ No newline at end of file From 3e05e45d70d856aa5d2fd3668868e00978e95f68 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Fri, 23 Feb 2024 07:52:37 +0000 Subject: [PATCH 02/42] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?=20GitHub=20CLI=20feature=20to=20devcontainer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6d41ddd..c9befdf 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,8 @@ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye", "features": { - "ghcr.io/devcontainers/features/rust:1": {} + "ghcr.io/devcontainers/features/rust:1": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} }, "customizations": { "vscode": { From 0b17a8e71b11ba9e6b2aeead987e9285f78e8d26 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Fri, 23 Feb 2024 07:54:16 +0000 Subject: [PATCH 03/42] =?UTF-8?q?=F0=9F=93=9D=20Add=20feedback=20issue=20t?= =?UTF-8?q?emplate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/feedback.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/feedback.md diff --git a/.github/ISSUE_TEMPLATE/feedback.md b/.github/ISSUE_TEMPLATE/feedback.md new file mode 100644 index 0000000..6f9a7a3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feedback.md @@ -0,0 +1,28 @@ +--- +name: "\U0001F4E3 Feedback" +about: Give us general feedback about the GitHub CLI +title: '' +labels: feedback +assignees: '' + +--- + +# CLI Feedback + +You can use this template to give us structured feedback or just wipe it and leave us a note. Thank you! + +## What have you loved? + +_eg "the nice colors"_ + +## What was confusing or gave you pause? + +_eg "it did something unexpected"_ + +## Are there features you'd like to see added? + +_eg "gh cli needs mini-games"_ + +## Anything else? + +_eg "have a nice day"_ \ No newline at end of file From 2c7d21d3786478b880a0760624f48b7f920716f0 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Fri, 23 Feb 2024 15:19:32 +0000 Subject: [PATCH 04/42] =?UTF-8?q?=F0=9F=93=9D=20Add=20code=20of=20conduct?= =?UTF-8?q?=20and=20contributing=20guidelines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CODE_OF_CONDUCT.md | 0 .github/CONTRIBUTING.md | 62 +++++++++++++++++++ README.md | 1 + 3 files changed, 63 insertions(+) rename CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md (100%) create mode 100644 .github/CONTRIBUTING.md diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..48b84d1 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,62 @@ +## Contributing + +Hi! Thanks for your interest in contributing to the Rust template! + +We accept pull requests for bug fixes and features where we've discussed the approach in an issue and given the go-ahead for a community member to work on it. We'd also love to hear about ideas for new features as issues. + +Please do: + +* Check existing issues to verify that the [bug][bug issues] or [feature request][feature request issues] has not already been submitted. +* Open an issue if things aren't working as expected. +* Open an issue to propose a significant change. +* Open a pull request to fix a bug. +* Open a pull request to fix documentation about a command. +* Open a pull request for any issue labelled [`help wanted`][hw] or [`good first issue`][gfi]. + +Please avoid: + +* Opening pull requests for issues marked `needs-design`, `needs-investigation`, or `blocked`. +* Opening pull requests that haven't been approved for work in an issue +* Adding installation instructions specifically for your OS/package manager. +* Opening pull requests for any issue marked `core`. These issues require additional context from + the core CLI team at GitHub and any external pull requests will not be accepted. + +## Building the project + +Prerequisites: +- rust or use the provided devcontainer + +Run tests with: `cargo test` + +## Submitting a pull request + +1. Create a new branch: `git checkout -b my-branch-name` +1. Make your change, add tests, and ensure tests pass +1. Submit a pull request + +Contributions to this project are [released][legal] to the public under the [project's open source license][license]. + +Please note that this project adheres to a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms. + +## Design guidelines + + +## Resources + +- [How to Contribute to Open Source][] +- [Using Pull Requests][] +- [GitHub Help][] + + +[bug issues]: https://github.com/MathieuSoysal/Exercism-Rust-Template/issues?q=is%3Aopen+is%3Aissue+label%3Abug +[feature request issues]: https://github.com/MathieuSoysal/Exercism-Rust-Template/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement +[hw]: https://github.com/MathieuSoysal/Exercism-Rust-Template/labels/help%20wanted +[gfi]: https://github.com/MathieuSoysal/Exercism-Rust-Template/labels/good%20first%20issue +[legal]: https://docs.github.com/en/free-pro-team@latest/github/site-policy/github-terms-of-service#6-contributions-under-repository-license +[license]: ../LICENSE +[code-of-conduct]: ./CODE-OF-CONDUCT.md +[How to Contribute to Open Source]: https://opensource.guide/how-to-contribute/ +[Using Pull Requests]: https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/about-pull-requests +[GitHub Help]: https://docs.github.com/ +[CLI Design System]: https://primer.style/cli/ +[Google Docs Template]: https://docs.google.com/document/d/1JIRErIUuJ6fTgabiFYfCH3x91pyHuytbfa0QLnTfXKM/edit#heading=h.or54sa47ylpg \ No newline at end of file diff --git a/README.md b/README.md index 809dfde..f37c675 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Basic Rust template with rust devcontainer and some CI to test and track benchma ## Customizing template ### Ctrl + Shift + F for replace: +- [ ] `Rust template` -> with your project name - [ ] `template-exercisme` -> with your rust project name - [ ] `Exercism-Rust-Template` -> with your GitHub repository name - [ ] `rust-template` -> with your Bencher project name From dbc969bebd9b1cb00d74f38c45ed172b33f5928d Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Fri, 23 Feb 2024 19:39:19 +0000 Subject: [PATCH 05/42] =?UTF-8?q?=F0=9F=93=9D=20Add=20pull=20request=20tem?= =?UTF-8?q?plate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/PULL_REQUEST_TEMPLATE.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..237763b --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,27 @@ + + + + +#### Description + + +#### Motivation and Context + + +closes # + +#### Screenshots (if appropriate): + +#### How Has This Been Tested? + + + +- [ ] I have tested using **MacOS** +- [ ] I have tested using **Linux** +- [ ] I have tested using **Windows** + +#### Checklist: + + +- [ ] I have updated the documentation accordingly. +- [ ] I have updated the tests accordingly. \ No newline at end of file From 4f806a082db2f69fe37540a6c1133d79c2a90ccb Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sat, 24 Feb 2024 20:29:39 +0000 Subject: [PATCH 06/42] Add release CI --- .github/workflows/release.yml | 171 +++++++++ Cargo.toml | 2 +- README.md | 8 +- install/install.sh | 448 ++++++++++++++++++++++ install/windows/main.wxs | 182 +++++++++ install/windows/pkg_resources/Banner.bmp | Bin 0 -> 119819 bytes install/windows/pkg_resources/Dialog.bmp | Bin 0 -> 119819 bytes install/windows/pkg_resources/LICENSE.rtf | 4 + 8 files changed, 813 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 install/install.sh create mode 100644 install/windows/main.wxs create mode 100644 install/windows/pkg_resources/Banner.bmp create mode 100644 install/windows/pkg_resources/Dialog.bmp create mode 100644 install/windows/pkg_resources/LICENSE.rtf diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..99e7ccd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,171 @@ +name: Cargo release + +on: + release: + types: [created] + +env: + CARGO_INCREMENTAL: 0 + CARGO_NET_RETRY: 10 + RUST_BACKTRACE: short + RUSTUP_MAX_RETRIES: 10 + MACOSX_DEPLOYMENT_TARGET: 10.7 + +jobs: + + # Build sources for every OS + cargo_build: + name: Build release binaries + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + name: rust-template-x86_64-unknown-linux-gnu.tar.gz + + - target: x86_64-unknown-linux-musl + os: ubuntu-latest + name: rust-template-x86_64-unknown-linux-musl.tar.gz + + - target: i686-unknown-linux-musl + os: ubuntu-latest + name: rust-template-i686-unknown-linux-musl.tar.gz + + - target: aarch64-unknown-linux-musl + os: ubuntu-latest + name: rust-template-aarch64-unknown-linux-musl.tar.gz + + - target: arm-unknown-linux-musleabihf + os: ubuntu-latest + name: rust-template-arm-unknown-linux-musleabihf.tar.gz + + - target: x86_64-apple-darwin + os: macOS-11 + name: rust-template-x86_64-apple-darwin.tar.gz + + - target: aarch64-apple-darwin + os: macOS-11 + name: rust-template-aarch64-apple-darwin.tar.gz + + - target: x86_64-pc-windows-msvc + os: windows-latest + name: rust-template-x86_64-pc-windows-msvc.zip + rustflags: -C target-feature=+crt-static + + - target: i686-pc-windows-msvc + os: windows-latest + name: rust-template-i686-pc-windows-msvc.zip + rustflags: -C target-feature=+crt-static + + - target: aarch64-pc-windows-msvc + os: windows-latest + name: rust-template-aarch64-pc-windows-msvc.zip + rustflags: -C target-feature=+crt-static + + - target: x86_64-unknown-freebsd + os: ubuntu-latest + name: rust-template-x86_64-unknown-freebsd.tar.gz + + runs-on: ${{ matrix.os }} + continue-on-error: true + env: + RUSTFLAGS: ${{ matrix.rustflags || '' }} + steps: + - name: Setup | Checkout + uses: actions/checkout@v4 + + - name: Setup | Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly + target: ${{ matrix.target }} + + - name: Setup | Install cargo-wix [Windows] + continue-on-error: true + # aarch64 is only supported in wix 4.0 development builds + if: matrix.os == 'windows-latest' && matrix.target != 'aarch64-pc-windows-msvc' + run: cargo install --version 0.3.4 cargo-wix + env: + # cargo-wix does not require static crt + RUSTFLAGS: "" + + - name: Setup | Install cross [Linux] + if: matrix.os == 'ubuntu-latest' + uses: taiki-e/install-action@cross + + - name: Build | Build [Cargo] + if: matrix.os != 'ubuntu-latest' + run: cargo build --release --locked --target ${{ matrix.target }} + + - name: Build | Build [Cross] + if: matrix.os == 'ubuntu-latest' + run: cross build --release --locked --target ${{ matrix.target }} + + - name: Build | Installer [Windows] + continue-on-error: true + if: matrix.os == 'windows-latest' && matrix.target != 'aarch64-pc-windows-msvc' + run: > + cargo wix -v --no-build --nocapture -I install/windows/main.wxs + --target ${{ matrix.target }} + --output target/wix/rust-template-${{ matrix.target }}.msi + + - name: Post Build | Prepare artifacts [Windows] + if: matrix.os == 'windows-latest' + run: | + cd target/${{ matrix.target }}/release + 7z a ../../../${{ matrix.name }} rust-template.exe + cd - + + - name: Post Build | Prepare artifacts [-nix] + if: matrix.os != 'windows-latest' + run: | + cd target/${{ matrix.target }}/release + tar czvf ../../../${{ matrix.name }} rust-template + cd - + + - name: Release | Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.name }} + path: ${{ matrix.name }} + + - name: Release | Upload installer artifacts [Windows] + continue-on-error: true + if: matrix.os == 'windows-latest' && matrix.target != 'aarch64-pc-windows-msvc' + uses: actions/upload-artifact@v4 + with: + name: rust-template-${{ matrix.target }}.msi + path: target/wix/rust-template-${{ matrix.target }}.msi + + + upload_artifacts: + name: Add Build Artifacts to Release + needs: [cargo_build] + runs-on: ubuntu-latest + steps: + - name: Setup | Artifacts + uses: actions/download-artifact@v4 + + - name: Setup | Checksums + run: for file in rust-template-*/rust-template-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done + + - name: Build | Add Artifacts to Release + uses: softprops/action-gh-release@v1 + with: + files: rust-template-*/rust-template-* + tag_name: ${{ github.ref }} + + # Publish rust-template to Crates.io + cargo_publish: + name: Publish Cargo Package + runs-on: ubuntu-latest + steps: + - name: Setup | Checkout + uses: actions/checkout@v4 + + - name: Setup | Rust + uses: dtolnay/rust-toolchain@nightly + + - name: Build | Publish + run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index f68fbda..30dd771 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "template_exercisme" -escription = "A template for exercism exercises in Rust" +description = "A template for exercism exercises in Rust" repository = "https://github.com/MathieuSoysal/Exercism-Rust-Template" readme = "README.md" version = "0.1.0" diff --git a/README.md b/README.md index f37c675..bda41bb 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ [![codecov](https://codecov.io/gh/MathieuSoysal/Exercism-Rust-Template/graph/badge.svg?token=MrM1EEfgvD)](https://codecov.io/gh/MathieuSoysal/Exercism-Rust-Template) [![Integration test for Rust](https://github.com/MathieuSoysal/Exercism-Rust-Template/actions/workflows/integration-test.yml/badge.svg)](https://github.com/MathieuSoysal/Exercism-Rust-Template/actions/workflows/integration-test.yml) +[Conventionnal Commits](https://www.conventionalcommits.org/en/v1.0.0/) + Basic Rust template with rust devcontainer and some CI to test and track benchmarcks automatically. @@ -11,6 +13,8 @@ Basic Rust template with rust devcontainer and some CI to test and track benchma - Benchmark tool : https://bencher.dev/learn/benchmarking/rust/libtest-bench/ - Benchmark CI : https://bencher.dev/docs/how-to/github-actions/ - mutation testing : https://mutants.rs +- Code coverage : https://codecov.io/gh/MathieuSoysal/Exercism-Rust-Template +- Crate publish: https://crates.io/settings/tokens ## Customizing template @@ -21,7 +25,9 @@ Basic Rust template with rust devcontainer and some CI to test and track benchma - [ ] `rust-template` -> with your Bencher project name - [ ] `MathieuSoysal` -> with your GitHub username - [ ] `2024` -> with the current year +- [ ] `A template for exercism exercises in Rust` -> with your project description ### Secrets - [ ] Add `BENCHER_API_KEY` in your repository secrets -- [ ] Add `CODECOV_TOKEN` in your repository secrets \ No newline at end of file +- [ ] Add `CODECOV_TOKEN` in your repository secrets +- [ ] Add `CARGO_REGISTRY_TOKEN` in your repository secrets \ No newline at end of file diff --git a/install/install.sh b/install/install.sh new file mode 100644 index 0000000..0eb1809 --- /dev/null +++ b/install/install.sh @@ -0,0 +1,448 @@ +#!/usr/bin/env sh + +set -eu +printf '\n' + +BOLD="$(tput bold 2>/dev/null || printf '')" +GREY="$(tput setaf 0 2>/dev/null || printf '')" +UNDERLINE="$(tput smul 2>/dev/null || printf '')" +RED="$(tput setaf 1 2>/dev/null || printf '')" +GREEN="$(tput setaf 2 2>/dev/null || printf '')" +YELLOW="$(tput setaf 3 2>/dev/null || printf '')" +BLUE="$(tput setaf 4 2>/dev/null || printf '')" +MAGENTA="$(tput setaf 5 2>/dev/null || printf '')" +NO_COLOR="$(tput sgr0 2>/dev/null || printf '')" + +SUPPORTED_TARGETS="x86_64-unknown-linux-gnu x86_64-unknown-linux-musl \ + i686-unknown-linux-musl aarch64-unknown-linux-musl \ + arm-unknown-linux-musleabihf x86_64-apple-darwin \ + aarch64-apple-darwin x86_64-pc-windows-msvc \ + i686-pc-windows-msvc aarch64-pc-windows-msvc \ + x86_64-unknown-freebsd" + +info() { + printf '%s\n' "${BOLD}${GREY}>${NO_COLOR} $*" +} + +warn() { + printf '%s\n' "${YELLOW}! $*${NO_COLOR}" +} + +error() { + printf '%s\n' "${RED}x $*${NO_COLOR}" >&2 +} + +completed() { + printf '%s\n' "${GREEN}βœ“${NO_COLOR} $*" +} + +has() { + command -v "$1" 1>/dev/null 2>&1 +} + +curl_is_snap() { + curl_path="$(command -v curl)" + case "$curl_path" in + /snap/*) return 0 ;; + *) return 1 ;; + esac +} + +# Make sure user is not using zsh or non-POSIX-mode bash, which can cause issues +verify_shell_is_posix_or_exit() { + if [ -n "${ZSH_VERSION+x}" ]; then + error "Running installation script with \`zsh\` is known to cause errors." + error "Please use \`sh\` instead." + exit 1 + elif [ -n "${BASH_VERSION+x}" ] && [ -z "${POSIXLY_CORRECT+x}" ]; then + error "Running installation script with non-POSIX \`bash\` may cause errors." + error "Please use \`sh\` instead." + exit 1 + else + true # No-op: no issues detected + fi +} + +get_tmpfile() { + suffix="$1" + if has mktemp; then + printf "%s.%s" "$(mktemp)" "${suffix}" + else + # No really good options here--let's pick a default + hope + printf "/tmp/starship.%s" "${suffix}" + fi +} + +# Test if a location is writeable by trying to write to it. Windows does not let +# you test writeability other than by writing: https://stackoverflow.com/q/1999988 +test_writeable() { + path="${1:-}/test.txt" + if touch "${path}" 2>/dev/null; then + rm "${path}" + return 0 + else + return 1 + fi +} + +download() { + file="$1" + url="$2" + + if has curl && curl_is_snap; then + warn "curl installed through snap cannot download Rust template." + warn "See https://github.com/MathieuSoysal/Exercism-Rust-Template/issues/5403 for details." + warn "Searching for other HTTP download programs..." + fi + + if has curl && ! curl_is_snap; then + cmd="curl --fail --silent --location --output $file $url" + elif has wget; then + cmd="wget --quiet --output-document=$file $url" + elif has fetch; then + cmd="fetch --quiet --output=$file $url" + else + error "No HTTP download program (curl, wget, fetch) found, exiting…" + return 1 + fi + + $cmd && return 0 || rc=$? + + error "Command failed (exit code $rc): ${BLUE}${cmd}${NO_COLOR}" + printf "\n" >&2 + info "This is likely due to Rust template not yet supporting your configuration." + info "If you would like to see a build for your configuration," + info "please create an issue requesting a build for ${MAGENTA}${TARGET}${NO_COLOR}:" + info "${BOLD}${UNDERLINE}https://github.com/MathieuSoysal/Exercism-Rust-Template/issues/new/${NO_COLOR}" + return $rc +} + +unpack() { + archive=$1 + bin_dir=$2 + sudo=${3-} + + case "$archive" in + *.tar.gz) + flags=$(test -n "${VERBOSE-}" && echo "-xzvof" || echo "-xzof") + ${sudo} tar "${flags}" "${archive}" -C "${bin_dir}" + return 0 + ;; + *.zip) + flags=$(test -z "${VERBOSE-}" && echo "-qqo" || echo "-o") + UNZIP="${flags}" ${sudo} unzip "${archive}" -d "${bin_dir}" + return 0 + ;; + esac + + error "Unknown package extension." + printf "\n" + info "This almost certainly results from a bug in this script--please file a" + info "bug report at https://github.com/MathieuSoysal/Exercism-Rust-Template/issues" + return 1 +} + +usage() { + printf "%s\n" \ + "install.sh [option]" \ + "" \ + "Fetch and install the latest version of Rust template, if Rust template is already" \ + "installed it will be updated to the latest version." + + printf "\n%s\n" "Options" + printf "\t%s\n\t\t%s\n\n" \ + "-V, --verbose" "Enable verbose output for the installer" \ + "-f, -y, --force, --yes" "Skip the confirmation prompt during installation" \ + "-p, --platform" "Override the platform identified by the installer [default: ${PLATFORM}]" \ + "-b, --bin-dir" "Override the bin installation directory [default: ${BIN_DIR}]" \ + "-a, --arch" "Override the architecture identified by the installer [default: ${ARCH}]" \ + "-B, --base-url" "Override the base URL used for downloading releases [default: ${BASE_URL}]" \ + "-h, --help" "Display this help message" +} + +elevate_priv() { + if ! has sudo; then + error 'Could not find the command "sudo", needed to get permissions for install.' + info "If you are on Windows, please run your shell as an administrator, then" + info "rerun this script. Otherwise, please run this script as root, or install" + info "sudo." + exit 1 + fi + if ! sudo -v; then + error "Superuser not granted, aborting installation" + exit 1 + fi +} + +install() { + ext="$1" + + if test_writeable "${BIN_DIR}"; then + sudo="" + msg="Installing Rust template, please wait…" + else + warn "Escalated permissions are required to install to ${BIN_DIR}" + elevate_priv + sudo="sudo" + msg="Installing Rust template as root, please wait…" + fi + info "$msg" + + archive=$(get_tmpfile "$ext") + + # download to the temp file + download "${archive}" "${URL}" + + # unpack the temp file to the bin dir, using sudo if required + unpack "${archive}" "${BIN_DIR}" "${sudo}" +} + +# Currently supporting: +# - win (Git Bash) +# - darwin +# - linux +# - linux_musl (Alpine) +# - freebsd +detect_platform() { + platform="$(uname -s | tr '[:upper:]' '[:lower:]')" + + case "${platform}" in + msys_nt*) platform="pc-windows-msvc" ;; + cygwin_nt*) platform="pc-windows-msvc";; + # mingw is Git-Bash + mingw*) platform="pc-windows-msvc" ;; + # use the statically compiled musl bins on linux to avoid linking issues. + linux) platform="unknown-linux-musl" ;; + darwin) platform="apple-darwin" ;; + freebsd) platform="unknown-freebsd" ;; + esac + + printf '%s' "${platform}" +} + +# Currently supporting: +# - x86_64 +# - i386 +# - arm +# - arm64 +detect_arch() { + arch="$(uname -m | tr '[:upper:]' '[:lower:]')" + + case "${arch}" in + amd64) arch="x86_64" ;; + armv*) arch="arm" ;; + arm64) arch="aarch64" ;; + esac + + # `uname -m` in some cases mis-reports 32-bit OS as 64-bit, so double check + if [ "${arch}" = "x86_64" ] && [ "$(getconf LONG_BIT)" -eq 32 ]; then + arch=i686 + elif [ "${arch}" = "aarch64" ] && [ "$(getconf LONG_BIT)" -eq 32 ]; then + arch=arm + fi + + printf '%s' "${arch}" +} + +detect_target() { + arch="$1" + platform="$2" + target="$arch-$platform" + + if [ "${target}" = "arm-unknown-linux-musl" ]; then + target="${target}eabihf" + fi + + printf '%s' "${target}" +} + + +confirm() { + if [ -z "${FORCE-}" ]; then + printf "%s " "${MAGENTA}?${NO_COLOR} $* ${BOLD}[y/N]${NO_COLOR}" + set +e + read -r yn &2 + info "If you would like to see a build for your configuration," + info "please create an issue requesting a build for ${MAGENTA}${target}${NO_COLOR}:" + info "${BOLD}${UNDERLINE}https://github.com/MathieuSoysal/Exercism-Rust-Template/issues/new/${NO_COLOR}" + printf "\n" + exit 1 + fi +} + +# defaults +if [ -z "${PLATFORM-}" ]; then + PLATFORM="$(detect_platform)" +fi + +if [ -z "${BIN_DIR-}" ]; then + BIN_DIR=/usr/local/bin +fi + +if [ -z "${ARCH-}" ]; then + ARCH="$(detect_arch)" +fi + +if [ -z "${BASE_URL-}" ]; then + BASE_URL="https://github.com/MathieuSoysal/Exercism-Rust-Template/releases" +fi + +# Non-POSIX shells can break once executing code due to semantic differences +verify_shell_is_posix_or_exit + +# parse argv variables +while [ "$#" -gt 0 ]; do + case "$1" in + -p | --platform) + PLATFORM="$2" + shift 2 + ;; + -b | --bin-dir) + BIN_DIR="$2" + shift 2 + ;; + -a | --arch) + ARCH="$2" + shift 2 + ;; + -B | --base-url) + BASE_URL="$2" + shift 2 + ;; + + -V | --verbose) + VERBOSE=1 + shift 1 + ;; + -f | -y | --force | --yes) + FORCE=1 + shift 1 + ;; + -h | --help) + usage + exit + ;; + + -p=* | --platform=*) + PLATFORM="${1#*=}" + shift 1 + ;; + -b=* | --bin-dir=*) + BIN_DIR="${1#*=}" + shift 1 + ;; + -a=* | --arch=*) + ARCH="${1#*=}" + shift 1 + ;; + -B=* | --base-url=*) + BASE_URL="${1#*=}" + shift 1 + ;; + -V=* | --verbose=*) + VERBOSE="${1#*=}" + shift 1 + ;; + -f=* | -y=* | --force=* | --yes=*) + FORCE="${1#*=}" + shift 1 + ;; + + *) + error "Unknown option: $1" + usage + exit 1 + ;; + esac +done + +TARGET="$(detect_target "${ARCH}" "${PLATFORM}")" + +is_build_available "${ARCH}" "${PLATFORM}" "${TARGET}" + +printf " %s\n" "${UNDERLINE}Configuration${NO_COLOR}" +info "${BOLD}Bin directory${NO_COLOR}: ${GREEN}${BIN_DIR}${NO_COLOR}" +info "${BOLD}Platform${NO_COLOR}: ${GREEN}${PLATFORM}${NO_COLOR}" +info "${BOLD}Arch${NO_COLOR}: ${GREEN}${ARCH}${NO_COLOR}" + +# non-empty VERBOSE enables verbose untarring +if [ -n "${VERBOSE-}" ]; then + VERBOSE=v + info "${BOLD}Verbose${NO_COLOR}: yes" +else + VERBOSE= +fi + +printf '\n' + +EXT=tar.gz +if [ "${PLATFORM}" = "pc-windows-msvc" ]; then + EXT=zip +fi + +URL="${BASE_URL}/latest/download/starship-${TARGET}.${EXT}" +info "Tarball URL: ${UNDERLINE}${BLUE}${URL}${NO_COLOR}" +confirm "Install Rust template ${GREEN}latest${NO_COLOR} to ${BOLD}${GREEN}${BIN_DIR}${NO_COLOR}?" +check_bin_dir "${BIN_DIR}" + +install "${EXT}" +completed "Rust template installed" + +printf '\n' diff --git a/install/windows/main.wxs b/install/windows/main.wxs new file mode 100644 index 0000000..cea9697 --- /dev/null +++ b/install/windows/main.wxs @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 1 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/install/windows/pkg_resources/Banner.bmp b/install/windows/pkg_resources/Banner.bmp new file mode 100644 index 0000000000000000000000000000000000000000..d087b1b2e56277208c00f1ba56af09ad5e9ff495 GIT binary patch literal 119819 zcmeI5-H%n(8He#g40DWMQ7=SWqezu%02@uT>5W%v(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 2024 21:41:40 +0000 Subject: [PATCH 07/42] docs: Add installation instructions for different operating systems --- README.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bda41bb..46cb362 100644 --- a/README.md +++ b/README.md @@ -30,4 +30,32 @@ Basic Rust template with rust devcontainer and some CI to test and track benchma ### Secrets - [ ] Add `BENCHER_API_KEY` in your repository secrets - [ ] Add `CODECOV_TOKEN` in your repository secrets -- [ ] Add `CARGO_REGISTRY_TOKEN` in your repository secrets \ No newline at end of file +- [ ] Add `CARGO_REGISTRY_TOKEN` in your repository secrets + +## Install + + +
+MacOS +Install the latest version for your system: + +```bash +curl -sS https://raw.githubusercontent.com/MathieuSoysal/Exercisme-Rust-Template/main/install/install.sh | sh +``` +
+ +
+Linux + +Install the latest version for your system: +```bash +curl -sS https://raw.githubusercontent.com/MathieuSoysal/Exercisme-Rust-Template/main/install/install.sh | sh +``` +
+ +
+Windows + +Install the latest version for your system: [Install](https://github.com/MathieuSoysal/Exercisme-Rust-Template/releases/latest/download/starship-x86_64-pc-windows-msvc.msi) + +
\ No newline at end of file From 9dfbd40f59f1a67bd7e7dfb39799ec8d98dddbe1 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sat, 24 Feb 2024 21:52:50 +0000 Subject: [PATCH 08/42] docs: Add new presentation sections to readme --- README.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 46cb362..8aaad44 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [Conventionnal Commits](https://www.conventionalcommits.org/en/v1.0.0/) -Basic Rust template with rust devcontainer and some CI to test and track benchmarcks automatically. +Rust template that contains automatic benchmarking, automatic mutation testing, automatic fuzz testing. ## Resources @@ -25,14 +25,14 @@ Basic Rust template with rust devcontainer and some CI to test and track benchma - [ ] `rust-template` -> with your Bencher project name - [ ] `MathieuSoysal` -> with your GitHub username - [ ] `2024` -> with the current year -- [ ] `A template for exercism exercises in Rust` -> with your project description +- [ ] `Rust template that contains automatic benchmarking, automatic mutation testing, automatic fuzz testing. ` -> with your project description ### Secrets - [ ] Add `BENCHER_API_KEY` in your repository secrets - [ ] Add `CODECOV_TOKEN` in your repository secrets - [ ] Add `CARGO_REGISTRY_TOKEN` in your repository secrets -## Install +## πŸš€ Installation
@@ -58,4 +58,19 @@ curl -sS https://raw.githubusercontent.com/MathieuSoysal/Exercisme-Rust-Template Install the latest version for your system: [Install](https://github.com/MathieuSoysal/Exercisme-Rust-Template/releases/latest/download/starship-x86_64-pc-windows-msvc.msi) -
\ No newline at end of file + + +## 🀝 Contributing + +We are always looking for contributors of **all skill levels**! If you're looking to ease your way into the project, try out a [good first issue](https://github.com/MathieuSoysal/Exercism-Rust-Template/labels/🌱%20good%20first%20issue). + +If you are interested in helping contribute to Rust template, don't hesitate to create your issue [Create new Issue](https://github.com/MathieuSoysal/Exercism-Rust-Template/issues/new/choose). + +## πŸ“ License + +Copyright Β© 2019-present, [Rust template Contributors](https://github.com/MathieuSoysal/Exercism-Rust-Template/graphs/contributors).
+This project is [ISC](https://github.com/MathieuSoysal/Exercism-Rust-Template/blob/main/LICENSE) licensed. + +## ⭐️ Support project + +If you like this project, feel free to support it by clicking on the ⭐️ button. \ No newline at end of file From 843435d2e2458dc3958b94d0810354660e4d4414 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sat, 24 Feb 2024 21:53:01 +0000 Subject: [PATCH 09/42] docs: Update project description and installer description --- Cargo.toml | 2 +- install/windows/main.wxs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 30dd771..f07a6a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "template_exercisme" -description = "A template for exercism exercises in Rust" +description = "Rust template that contains automatic benchmarking, automatic mutation testing, automatic fuzz testing. " repository = "https://github.com/MathieuSoysal/Exercism-Rust-Template" readme = "README.md" version = "0.1.0" diff --git a/install/windows/main.wxs b/install/windows/main.wxs index cea9697..c8ece4e 100644 --- a/install/windows/main.wxs +++ b/install/windows/main.wxs @@ -61,7 +61,7 @@ - + From f3d88403fddeba2288a5bce86a8da2b1d29dde80 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sat, 24 Feb 2024 22:04:52 +0000 Subject: [PATCH 10/42] docs: Add documentation issue template --- .github/ISSUE_TEMPLATE/documentation.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/documentation.yml diff --git a/.github/ISSUE_TEMPLATE/documentation.yml b/.github/ISSUE_TEMPLATE/documentation.yml new file mode 100644 index 0000000..9542525 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.yml @@ -0,0 +1,24 @@ +name: Documentation problem +description: Create a report for a documentation problem. +labels: ["documentation"] +body: + - type: markdown + attributes: + value: | + Thank you for finding a documentation problem! πŸ“š + + Documentation problems might be grammatical issues, typos, or unclear wording, please provide details regarding the documentation including where it is present. + + - type: textarea + id: location + attributes: + label: Location + validations: + required: true + + - type: textarea + id: summary + attributes: + label: Summary + validations: + required: true \ No newline at end of file From c2e8a9e9c2f77bc7315e35d8883083f593c6c833 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sun, 25 Feb 2024 08:22:09 +0000 Subject: [PATCH 11/42] =?UTF-8?q?=F0=9F=93=9D=20Update=20pull=20request=20?= =?UTF-8?q?template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/PULL_REQUEST_TEMPLATE.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 237763b..038eef3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,17 +2,17 @@ -#### Description +## Description -#### Motivation and Context +## Motivation and Context closes # -#### Screenshots (if appropriate): +## Screenshots (if appropriate): -#### How Has This Been Tested? +## How Has This Been Tested? @@ -20,8 +20,16 @@ closes # - [ ] I have tested using **Linux** - [ ] I have tested using **Windows** -#### Checklist: +## Checklist: - [ ] I have updated the documentation accordingly. -- [ ] I have updated the tests accordingly. \ No newline at end of file +- [ ] I have updated the tests accordingly. + +## Migration Guide + +> This section is optional. If there are no breaking changes, you can delete this section. + +- If this PR is a breaking change (relative to the last release of Bevy), describe how a user might need to migrate their code to support these changes +- Simply adding new functionality is not a breaking change. +- Fixing behavior that was definitely a bug, rather than a questionable design choice is not a breaking change. \ No newline at end of file From 0fc6dc11ff48b56147afed74222e61a3626cb0d3 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sun, 25 Feb 2024 08:22:24 +0000 Subject: [PATCH 12/42] =?UTF-8?q?=F0=9F=93=9D=20Add=20quick=20start=20cont?= =?UTF-8?q?ributing=20section?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 8aaad44..d6eb046 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,10 @@ We are always looking for contributors of **all skill levels**! If you're lookin If you are interested in helping contribute to Rust template, don't hesitate to create your issue [Create new Issue](https://github.com/MathieuSoysal/Exercism-Rust-Template/issues/new/choose). +###Β πŸš€ Quick start contributing + +**Quick start contributing** you just need to click to this link [Start Online Devcontainer](https://codespaces.new/MathieuSoysal/Exercism-Rust-Template?quickstart=1) to automatically create a development environment for this project and start contributing ;) and you can also read the [CONTRIBUTING.md](./.github/CONTRIBUTING.md) + ## πŸ“ License Copyright Β© 2019-present, [Rust template Contributors](https://github.com/MathieuSoysal/Exercism-Rust-Template/graphs/contributors).
From 0c13550c56d6acba81716fbed07b8cad0095ccf3 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sun, 25 Feb 2024 09:16:38 +0000 Subject: [PATCH 13/42] =?UTF-8?q?=F0=9F=91=B7=20Add=20stale.yml=20configur?= =?UTF-8?q?ation=20file=20for=20issue=20staleness?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/stale.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..8462989 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,17 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 14 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security +# Label to use when marking an issue as stale +staleLabel: wontfix +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false \ No newline at end of file From cb834f4b947984bb678bcddf068770874dba68d8 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Mon, 26 Feb 2024 00:46:20 +0000 Subject: [PATCH 14/42] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?=20Prusti=20Assistant=20extension=20to=20devcontainer.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c9befdf..2c1017b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,7 +18,8 @@ "ZhangYue.rust-mod-generator", "usernamehw.errorlens", "seatonjiang.gitmoji-vscode", - "github.vscode-github-actions" + "github.vscode-github-actions", + "viper-admin.prusti-assistant" ] }, "codespaces": { From ce7635af602bf714909ec8c5922ecc9265b34281 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Mon, 26 Feb 2024 00:46:30 +0000 Subject: [PATCH 15/42] =?UTF-8?q?=F0=9F=91=B7=20Add=20security=20audit=20w?= =?UTF-8?q?orkflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/security-audit.yml | 79 ++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/security-audit.yml diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml new file mode 100644 index 0000000..a4df4b2 --- /dev/null +++ b/.github/workflows/security-audit.yml @@ -0,0 +1,79 @@ +name: Security audit + +on: + push: + branches: + - $default-branch + pull_request: + +env: + RUST_BACKTRACE: 1 + CARGO_TERM_COLOR: always + CLICOLOR: 1 + +jobs: + cargo_udep: + name: Cargo check dependencies are used + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Rust nightly + uses: dtolnay/rust-toolchain@nightly + - name: Install udeps + run: cargo install cargo-udeps --locked --force + - name: Run udeps + run: cargo +nightly udeps + + security_audit: + permissions: + issues: write # to create issues (actions-rs/audit-check) + checks: write # to create check (actions-rs/audit-check) + runs-on: ubuntu-latest + # Prevent sudden announcement of a new advisory from failing ci: + continue-on-error: true + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - uses: actions-rs/audit-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + cargo_deny: + permissions: + issues: write # to create issues (actions-rs/audit-check) + checks: write # to create check (actions-rs/audit-check) + runs-on: ubuntu-latest + strategy: + matrix: + checks: + - bans licenses sources + steps: + - uses: actions/checkout@v4 + - uses: EmbarkStudios/cargo-deny-action@v1 + with: + command: check ${{ matrix.checks }} + rust-version: nightly + + cargo_prusti: + name: Cargo Prusti static analysis + permissions: + issues: write # to create issues (actions-rs/audit-check) + checks: write # to create check (actions-rs/audit-check) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: viperproject/prusti-action@master + with: + path: . + + cargo_Rudra: + name: Cargo Rudra check memory safety + runs-on: ubuntu-latest + steps: + - name: Rudra + uses: sslab-gatech/Rudra@master + + +# Possible other tools: +# https://github.com/model-checking/kani +# https://github.com/mcarton/rust-herbie-lint \ No newline at end of file From d7a3800a972b1837ede00e94c2e5cf759de48085 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Mon, 26 Feb 2024 00:46:42 +0000 Subject: [PATCH 16/42] =?UTF-8?q?=F0=9F=93=9D=20Add=20link=20to=20Crate=20?= =?UTF-8?q?prusti?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d6eb046..d6d7482 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Rust template that contains automatic benchmarking, automatic mutation testing, - mutation testing : https://mutants.rs - Code coverage : https://codecov.io/gh/MathieuSoysal/Exercism-Rust-Template - Crate publish: https://crates.io/settings/tokens +- Crate prusti : https://viperproject.github.io/prusti-dev/user-guide/tour/getting-started ## Customizing template From a4c62980e629e1c609d58dd72f7d8841affce49e Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Mon, 26 Feb 2024 22:29:23 +0000 Subject: [PATCH 17/42] =?UTF-8?q?=F0=9F=93=9D=20Add=20labeler.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/labeler.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/labeler.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..03f349a --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,38 @@ +# Configuration for Auto Labeler during pull request +# +# See https://github.com/actions/labeler for file format +# and https://github.com/google/flatbuffers/labels for a list of valid labels +# +# See .github/workflows/label.yml for Github Action workflow script + +rust: + - '**/*.rs' + - rust/**/* + - src/idl_gen_rust.cpp + +cargo: + - Cargo.toml + - Cargo.lock + - rust-toolchain + +code: + - src/**/* + +documentation: + - docs/**/* + - '**/*.md' + +CI: + - '.github/**/*' + - '.appveyor/**/*' + - '.travis/**/*' + - '.bazelci/**/*' + - .travis.yml + - appveyor.yml + +devcontainer: + - .devcontainer/**/* + +fuzzing: + - fuzz/**/* + From 5f05f24657d089d3b2b196512c0f2004bf629600 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Mon, 26 Feb 2024 22:46:12 +0000 Subject: [PATCH 18/42] =?UTF-8?q?=F0=9F=93=9D=20Add=20branch=20labels=20to?= =?UTF-8?q?=20labeler.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/labeler.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/labeler.yml b/.github/labeler.yml index 03f349a..aaee570 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -36,3 +36,35 @@ devcontainer: fuzzing: - fuzz/**/* +feature: + - head-branch: ['^feature', 'feature'] + +bug: + - head-branch: ['^bug', 'bug'] + +documentation: + - head-branch: ['^docs', 'docs'] + +chore: + - head-branch: ['^chore', 'chore'] + +ci: + - head-branch: ['^ci', 'ci'] + +build: + - head-branch: ['^build', 'build'] + +test: + - head-branch: ['^test', 'test'] + +perf: + - head-branch: ['^perf', 'perf'] + +fix: + - head-branch: ['^fix', 'fix'] + +refactor: + - head-branch: ['^refactor', 'refactor'] + +style: + - head-branch: ['^style', 'style'] \ No newline at end of file From 33c57860507072ef43bfe7f0c45fb53710a056f5 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Mon, 26 Feb 2024 22:48:39 +0000 Subject: [PATCH 19/42] Add commit-lint workflow This commit adds a new GitHub Actions workflow file named commit-lint.yml. The workflow checks if the commit messages follow conventional commit format. --- .github/workflows/commit-lint.yml | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/commit-lint.yml diff --git a/.github/workflows/commit-lint.yml b/.github/workflows/commit-lint.yml new file mode 100644 index 0000000..7b56897 --- /dev/null +++ b/.github/workflows/commit-lint.yml @@ -0,0 +1,36 @@ +name: Check if commit is conventional + +on: [push, pull_request] + +jobs: + commitlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install required dependencies + run: | + apt update + apt install -y sudo + sudo apt install -y git curl + curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - + sudo DEBIAN_FRONTEND=noninteractive apt install -y nodejs + - name: Print versions + run: | + git --version + node --version + npm --version + npx commitlint --version + - name: Install commitlint + run: | + npm install conventional-changelog-conventionalcommits + npm install commitlint@latest + + - name: Validate current commit (last commit) with commitlint + if: github.event_name == 'push' + run: npx commitlint --from HEAD~1 --to HEAD --verbose + + - name: Validate PR commits with commitlint + if: github.event_name == 'pull_request' + run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose \ No newline at end of file From 2019b0463be5b8c036a62e1f22cc60ac0f1ecb6b Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Fri, 1 Mar 2024 13:40:56 +0000 Subject: [PATCH 20/42] docs: fix typos --- README.md | 2 +- install/install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d6d7482..6e8d2da 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![codecov](https://codecov.io/gh/MathieuSoysal/Exercism-Rust-Template/graph/badge.svg?token=MrM1EEfgvD)](https://codecov.io/gh/MathieuSoysal/Exercism-Rust-Template) [![Integration test for Rust](https://github.com/MathieuSoysal/Exercism-Rust-Template/actions/workflows/integration-test.yml/badge.svg)](https://github.com/MathieuSoysal/Exercism-Rust-Template/actions/workflows/integration-test.yml) -[Conventionnal Commits](https://www.conventionalcommits.org/en/v1.0.0/) +[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) Rust template that contains automatic benchmarking, automatic mutation testing, automatic fuzz testing. diff --git a/install/install.sh b/install/install.sh index 0eb1809..cf82644 100644 --- a/install/install.sh +++ b/install/install.sh @@ -234,7 +234,7 @@ detect_arch() { arm64) arch="aarch64" ;; esac - # `uname -m` in some cases mis-reports 32-bit OS as 64-bit, so double check + # `uname -m` in some cases miss-reports 32-bit OS as 64-bit, so double check if [ "${arch}" = "x86_64" ] && [ "$(getconf LONG_BIT)" -eq 32 ]; then arch=i686 elif [ "${arch}" = "aarch64" ] && [ "$(getconf LONG_BIT)" -eq 32 ]; then From 5353fbddcb73a741cf815e6c3e7e593c8c05f841 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sun, 3 Mar 2024 16:07:18 +0000 Subject: [PATCH 21/42] fix: Add checkout step for Rudra workflow --- .github/workflows/security-audit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml index a4df4b2..8b5b415 100644 --- a/.github/workflows/security-audit.yml +++ b/.github/workflows/security-audit.yml @@ -70,6 +70,7 @@ jobs: name: Cargo Rudra check memory safety runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - name: Rudra uses: sslab-gatech/Rudra@master From 15fef2d92874340a5fad2779888469f8e9acb5e3 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sun, 3 Mar 2024 16:30:01 +0000 Subject: [PATCH 22/42] feat: Improve cargo-udeps installation command --- .github/workflows/security-audit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml index 8b5b415..44b8abd 100644 --- a/.github/workflows/security-audit.yml +++ b/.github/workflows/security-audit.yml @@ -20,7 +20,7 @@ jobs: - name: Install Rust nightly uses: dtolnay/rust-toolchain@nightly - name: Install udeps - run: cargo install cargo-udeps --locked --force + run: cargo binstall cargo-udeps - name: Run udeps run: cargo +nightly udeps From 220b357614e049a65d10e85fb7db39178ba5ea41 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sun, 3 Mar 2024 16:39:01 +0000 Subject: [PATCH 23/42] fix: Update security-audit.yml: Add cargo-binstall step --- .github/workflows/security-audit.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml index 44b8abd..ed93861 100644 --- a/.github/workflows/security-audit.yml +++ b/.github/workflows/security-audit.yml @@ -13,12 +13,14 @@ env: jobs: cargo_udep: - name: Cargo check dependencies are used + name: Cargo check dependencies runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install Rust nightly uses: dtolnay/rust-toolchain@nightly + - name: Install cargo-binstall + uses: cargo-bins/cargo-binstall@main - name: Install udeps run: cargo binstall cargo-udeps - name: Run udeps From 7a934b166b7ff72b5ac58f30ab5f41ea0b302825 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sun, 3 Mar 2024 17:01:04 +0000 Subject: [PATCH 24/42] fix: Add token parameter to Prusti action --- .github/workflows/security-audit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml index ed93861..f17a9f7 100644 --- a/.github/workflows/security-audit.yml +++ b/.github/workflows/security-audit.yml @@ -67,6 +67,7 @@ jobs: - uses: viperproject/prusti-action@master with: path: . + token: ${{ secrets.GITHUB_TOKEN }} cargo_Rudra: name: Cargo Rudra check memory safety From d6a64c6fed8e762006fb5b09af23419fd2f49c27 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sun, 3 Mar 2024 17:02:21 +0000 Subject: [PATCH 25/42] fix: Add write permission for pull requests in security audit workflow --- .github/workflows/security-audit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml index f17a9f7..f573c4a 100644 --- a/.github/workflows/security-audit.yml +++ b/.github/workflows/security-audit.yml @@ -61,6 +61,7 @@ jobs: permissions: issues: write # to create issues (actions-rs/audit-check) checks: write # to create check (actions-rs/audit-check) + pull-requests: write runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From d4a1beebcb2d7f1b6c7c21ddef9dce273b540feb Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sun, 3 Mar 2024 17:16:02 +0000 Subject: [PATCH 26/42] feat: Add prusti-contracts dependency --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index f07a6a5..07b473f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dev-dependencies] +prusti-contracts = "0.2.0" \ No newline at end of file From 2e3db33af8cca69851f54701502c37e797e91b71 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sun, 3 Mar 2024 17:36:46 +0000 Subject: [PATCH 27/42] fix: Add Java feature for Prusti --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2c1017b..f2c0d0f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,7 +6,8 @@ "image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye", "features": { "ghcr.io/devcontainers/features/rust:1": {}, - "ghcr.io/devcontainers/features/github-cli:1": {} + "ghcr.io/devcontainers/features/github-cli:1": {}, + "ghcr.io/devcontainers/features/java:1": {} // Used for Prusti }, "customizations": { "vscode": { From 8accdea5e3eb0d08636bb77a999822ac6cb00230 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sun, 3 Mar 2024 17:38:35 +0000 Subject: [PATCH 28/42] fix: Update cargo-udeps installation command --- .github/workflows/security-audit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml index f573c4a..0ea93ad 100644 --- a/.github/workflows/security-audit.yml +++ b/.github/workflows/security-audit.yml @@ -22,7 +22,7 @@ jobs: - name: Install cargo-binstall uses: cargo-bins/cargo-binstall@main - name: Install udeps - run: cargo binstall cargo-udeps + run: cargo binstall cargo-udeps -y - name: Run udeps run: cargo +nightly udeps From 3f55d85cab4a71b19ce1632e9893ee114ba3a6bc Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:22:20 +0000 Subject: [PATCH 29/42] feat: Add Cargo lockbud check for deadlocks --- .github/workflows/security-audit.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml index 0ea93ad..acab363 100644 --- a/.github/workflows/security-audit.yml +++ b/.github/workflows/security-audit.yml @@ -78,6 +78,18 @@ jobs: - name: Rudra uses: sslab-gatech/Rudra@master + cargo_deadblock: + name: Cargo lockbud check for deadlocks + runs-on: ubuntu-latest + container: + image: burtonqin/lockbud + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Generate code coverage + run: | + cargo lockbud -k deadlock + # Possible other tools: # https://github.com/model-checking/kani From 9863c962d13701cb9c4a59b52655edbdfee59a4a Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:24:50 +0000 Subject: [PATCH 30/42] fix: Remove unused token in security-audit.yml workflow --- .github/workflows/security-audit.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml index acab363..0095b32 100644 --- a/.github/workflows/security-audit.yml +++ b/.github/workflows/security-audit.yml @@ -68,7 +68,6 @@ jobs: - uses: viperproject/prusti-action@master with: path: . - token: ${{ secrets.GITHUB_TOKEN }} cargo_Rudra: name: Cargo Rudra check memory safety From 935463d07e6a9fdfecf51e533332d04423d2d668 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:25:20 +0000 Subject: [PATCH 31/42] feat: Update dependencies and add contract annotation --- Cargo.toml | 2 +- src/lib.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 07b473f..13bd641 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,5 +10,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[dev-dependencies] +[dependencies] prusti-contracts = "0.2.0" \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 0ec90a1..e8c4957 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,13 +1,18 @@ #![feature(test)] extern crate test; +use prusti_contracts::*; + +const MAX_FIBONACCI: u32 = 2_971_215_073; + pub fn play_game(n: u32) { println!("{}", fizz_buzz_fibonacci(n)); } +#[trusted] fn is_fibonacci_number(n: u32) -> bool { let (mut previous, mut current) = (0, 1); - while current < n && n <= 2971215073 { + while current < n && n <= MAX_FIBONACCI { let next = previous + current; previous = current; current = next; From ddc9f7270b270dc12237f553bceae4a237490c7a Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:35:09 +0000 Subject: [PATCH 32/42] fix(prusti): Add #[trusted] attribute to play_game functions --- src/lib.rs | 1 + src/main.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e8c4957..62c90e2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,7 @@ use prusti_contracts::*; const MAX_FIBONACCI: u32 = 2_971_215_073; +#[trusted] pub fn play_game(n: u32) { println!("{}", fizz_buzz_fibonacci(n)); } diff --git a/src/main.rs b/src/main.rs index 9804836..20ec39e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,11 @@ #![feature(test)] extern crate test; +use prusti_contracts::*; + use template_exercisme::play_game; +#[trusted] fn main() { let args: Vec = std::env::args().collect(); let i = args From 4927a48430ad214fb84e1635336b00cba88b84e0 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:41:19 +0000 Subject: [PATCH 33/42] fix: Remove cargo_prusti static analysis workflow --- .github/workflows/security-audit.yml | 24 ++++++++++++------------ Cargo.toml | 4 ++-- src/lib.rs | 4 ---- src/main.rs | 3 --- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml index 0095b32..5ecda8a 100644 --- a/.github/workflows/security-audit.yml +++ b/.github/workflows/security-audit.yml @@ -56,18 +56,18 @@ jobs: command: check ${{ matrix.checks }} rust-version: nightly - cargo_prusti: - name: Cargo Prusti static analysis - permissions: - issues: write # to create issues (actions-rs/audit-check) - checks: write # to create check (actions-rs/audit-check) - pull-requests: write - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: viperproject/prusti-action@master - with: - path: . + # cargo_prusti: + # name: Cargo Prusti static analysis + # permissions: + # issues: write # to create issues (actions-rs/audit-check) + # checks: write # to create check (actions-rs/audit-check) + # pull-requests: write + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: viperproject/prusti-action@master + # with: + # path: . cargo_Rudra: name: Cargo Rudra check memory safety diff --git a/Cargo.toml b/Cargo.toml index 13bd641..8534290 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,5 +10,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[dependencies] -prusti-contracts = "0.2.0" \ No newline at end of file +# [dependencies] +# prusti-contracts = "0.2.0" \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 62c90e2..d823bd7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,16 +1,12 @@ #![feature(test)] extern crate test; -use prusti_contracts::*; - const MAX_FIBONACCI: u32 = 2_971_215_073; -#[trusted] pub fn play_game(n: u32) { println!("{}", fizz_buzz_fibonacci(n)); } -#[trusted] fn is_fibonacci_number(n: u32) -> bool { let (mut previous, mut current) = (0, 1); while current < n && n <= MAX_FIBONACCI { diff --git a/src/main.rs b/src/main.rs index 20ec39e..9804836 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,8 @@ #![feature(test)] extern crate test; -use prusti_contracts::*; - use template_exercisme::play_game; -#[trusted] fn main() { let args: Vec = std::env::args().collect(); let i = args From 16c303890a2bb45cbed6eb51d557e076f8b868c5 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Thu, 7 Mar 2024 18:58:00 +0000 Subject: [PATCH 34/42] fix: Add Rust nightly installation step to security audit workflow --- .github/workflows/security-audit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml index 5ecda8a..307d8da 100644 --- a/.github/workflows/security-audit.yml +++ b/.github/workflows/security-audit.yml @@ -85,6 +85,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Install Rust nightly + uses: dtolnay/rust-toolchain@nightly - name: Generate code coverage run: | cargo lockbud -k deadlock From ea6375fe996d289768ebb79df9047954cc620e63 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Sat, 9 Mar 2024 12:50:29 +0000 Subject: [PATCH 35/42] fix: code coverage generation by setting LD_LIBRARY_PATH --- .github/workflows/security-audit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml index 307d8da..dfbb0cc 100644 --- a/.github/workflows/security-audit.yml +++ b/.github/workflows/security-audit.yml @@ -89,6 +89,7 @@ jobs: uses: dtolnay/rust-toolchain@nightly - name: Generate code coverage run: | + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib cargo lockbud -k deadlock From 5bfc1ae35efa4619dce1474292f8421b0d184781 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Wed, 13 Mar 2024 22:56:06 +0000 Subject: [PATCH 36/42] fix(ci) : security deadblock --- .github/workflows/security-audit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml index dfbb0cc..5aa6294 100644 --- a/.github/workflows/security-audit.yml +++ b/.github/workflows/security-audit.yml @@ -89,7 +89,7 @@ jobs: uses: dtolnay/rust-toolchain@nightly - name: Generate code coverage run: | - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib cargo lockbud -k deadlock From 3b9544abc9fb2ce0c06c53b0f51735a6de1c0bcf Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Thu, 14 Mar 2024 00:34:03 +0000 Subject: [PATCH 37/42] fix: Remove cargo_deadblock job from security-audit.yml --- .github/workflows/security-audit.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml index 5aa6294..c2f1b80 100644 --- a/.github/workflows/security-audit.yml +++ b/.github/workflows/security-audit.yml @@ -77,21 +77,6 @@ jobs: - name: Rudra uses: sslab-gatech/Rudra@master - cargo_deadblock: - name: Cargo lockbud check for deadlocks - runs-on: ubuntu-latest - container: - image: burtonqin/lockbud - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Install Rust nightly - uses: dtolnay/rust-toolchain@nightly - - name: Generate code coverage - run: | - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib - cargo lockbud -k deadlock - # Possible other tools: # https://github.com/model-checking/kani From 6c5d2886cf043f5d63a1b3624ecb1592389ee1c8 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Thu, 14 Mar 2024 00:48:58 +0000 Subject: [PATCH 38/42] fix(ci): Add permissions and environment variables to commit-lint workflow --- .github/workflows/commit-lint.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/commit-lint.yml b/.github/workflows/commit-lint.yml index 7b56897..1a77e63 100644 --- a/.github/workflows/commit-lint.yml +++ b/.github/workflows/commit-lint.yml @@ -2,7 +2,14 @@ name: Check if commit is conventional on: [push, pull_request] +permissions: + contents: read + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + jobs: + commitlint: runs-on: ubuntu-latest steps: From 85e9ecd3978495ded7d4e5dacbe92047174cdc93 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Thu, 14 Mar 2024 00:57:45 +0000 Subject: [PATCH 39/42] fix(ci): Update dependencies installation in commit-lint workflow --- .github/workflows/commit-lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/commit-lint.yml b/.github/workflows/commit-lint.yml index 1a77e63..292ab5b 100644 --- a/.github/workflows/commit-lint.yml +++ b/.github/workflows/commit-lint.yml @@ -18,8 +18,8 @@ jobs: fetch-depth: 0 - name: Install required dependencies run: | - apt update - apt install -y sudo + sudo apt update + sudo apt install -y sudo sudo apt install -y git curl curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo DEBIAN_FRONTEND=noninteractive apt install -y nodejs From 3e9b8767e691cf1952a8cc548bb7f9d1dac36004 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Thu, 14 Mar 2024 01:14:16 +0000 Subject: [PATCH 40/42] fix(ci) : Add commitlint.config.js configuration file --- commitlint.config.js | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 commitlint.config.js diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..8f8dd31 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,58 @@ +const Configuration = { + /* + * Resolve and load @commitlint/config-conventional from node_modules. + * Referenced packages must be installed + */ + extends: ['@commitlint/config-conventional'], + /* + * Resolve and load conventional-changelog-atom from node_modules. + * Referenced packages must be installed + */ + parserPreset: 'conventional-changelog-atom', + /* + * Resolve and load @commitlint/format from node_modules. + * Referenced package must be installed + */ + formatter: '@commitlint/format', + /* + * Any rules defined here will override rules from @commitlint/config-conventional + */ + rules: { + 'type-enum': [2, 'always', ['foo']], + }, + /* + * Array of functions that return true if commitlint should ignore the given message. + * Given array is merged with predefined functions, which consist of matchers like: + * + * - 'Merge pull request', 'Merge X into Y' or 'Merge branch X' + * - 'Revert X' + * - 'v1.2.3' (ie semver matcher) + * - 'Automatic merge X' or 'Auto-merged X into Y' + * + * To see full list, check https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/is-ignored/src/defaults.ts. + * To disable those ignores and run rules always, set `defaultIgnores: false` as shown below. + */ + ignores: [(commit) => commit === ''], + /* + * Whether commitlint uses the default ignore rules, see the description above. + */ + defaultIgnores: true, + /* + * Custom URL to show upon failure + */ + helpUrl: + 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint', + /* + * Custom prompt configs + */ + prompt: { + messages: {}, + questions: { + type: { + description: 'please input type:', + }, + }, + }, +}; + +export default Configuration; \ No newline at end of file From 0ca1a48d3147f1b8e4c395a78c81fb7614f0e547 Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Thu, 14 Mar 2024 01:40:09 +0000 Subject: [PATCH 41/42] fix(ci) : Update commitlint.config.js --- commitlint.config.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/commitlint.config.js b/commitlint.config.js index 8f8dd31..5d20fe6 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -53,6 +53,4 @@ const Configuration = { }, }, }, -}; - -export default Configuration; \ No newline at end of file +}; \ No newline at end of file From 95815df12bff13629a8d0005de2257ef3115d60d Mon Sep 17 00:00:00 2001 From: Mathieu Soysal <43273304+MathieuSoysal@users.noreply.github.com> Date: Thu, 14 Mar 2024 01:45:51 +0000 Subject: [PATCH 42/42] fix : Update commitlint configuration --- commitlint.config.js | 56 ----------------- commitlint.config.ts | 146 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 56 deletions(-) delete mode 100644 commitlint.config.js create mode 100644 commitlint.config.ts diff --git a/commitlint.config.js b/commitlint.config.js deleted file mode 100644 index 5d20fe6..0000000 --- a/commitlint.config.js +++ /dev/null @@ -1,56 +0,0 @@ -const Configuration = { - /* - * Resolve and load @commitlint/config-conventional from node_modules. - * Referenced packages must be installed - */ - extends: ['@commitlint/config-conventional'], - /* - * Resolve and load conventional-changelog-atom from node_modules. - * Referenced packages must be installed - */ - parserPreset: 'conventional-changelog-atom', - /* - * Resolve and load @commitlint/format from node_modules. - * Referenced package must be installed - */ - formatter: '@commitlint/format', - /* - * Any rules defined here will override rules from @commitlint/config-conventional - */ - rules: { - 'type-enum': [2, 'always', ['foo']], - }, - /* - * Array of functions that return true if commitlint should ignore the given message. - * Given array is merged with predefined functions, which consist of matchers like: - * - * - 'Merge pull request', 'Merge X into Y' or 'Merge branch X' - * - 'Revert X' - * - 'v1.2.3' (ie semver matcher) - * - 'Automatic merge X' or 'Auto-merged X into Y' - * - * To see full list, check https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/is-ignored/src/defaults.ts. - * To disable those ignores and run rules always, set `defaultIgnores: false` as shown below. - */ - ignores: [(commit) => commit === ''], - /* - * Whether commitlint uses the default ignore rules, see the description above. - */ - defaultIgnores: true, - /* - * Custom URL to show upon failure - */ - helpUrl: - 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint', - /* - * Custom prompt configs - */ - prompt: { - messages: {}, - questions: { - type: { - description: 'please input type:', - }, - }, - }, -}; \ No newline at end of file diff --git a/commitlint.config.ts b/commitlint.config.ts new file mode 100644 index 0000000..80164d4 --- /dev/null +++ b/commitlint.config.ts @@ -0,0 +1,146 @@ +import { + RuleConfigCondition, + RuleConfigSeverity, + TargetCaseType, +} from '@commitlint/types'; + +export default { + parserPreset: 'conventional-changelog-conventionalcommits', + rules: { + 'body-leading-blank': [RuleConfigSeverity.Warning, 'always'] as const, + 'body-max-line-length': [RuleConfigSeverity.Error, 'always', 100] as const, + 'footer-leading-blank': [RuleConfigSeverity.Warning, 'always'] as const, + 'footer-max-line-length': [ + RuleConfigSeverity.Error, + 'always', + 100, + ] as const, + 'header-max-length': [RuleConfigSeverity.Error, 'always', 100] as const, + 'header-trim': [RuleConfigSeverity.Error, 'always'] as const, + 'subject-case': [ + RuleConfigSeverity.Error, + 'never', + ['sentence-case', 'start-case', 'pascal-case', 'upper-case'], + ] as [RuleConfigSeverity, RuleConfigCondition, TargetCaseType[]], + 'subject-empty': [RuleConfigSeverity.Error, 'never'] as const, + 'subject-full-stop': [RuleConfigSeverity.Error, 'never', '.'] as const, + 'type-case': [RuleConfigSeverity.Error, 'always', 'lower-case'] as const, + 'type-empty': [RuleConfigSeverity.Error, 'never'] as const, + 'type-enum': [ + RuleConfigSeverity.Error, + 'always', + [ + 'build', + 'chore', + 'ci', + 'docs', + 'feat', + 'fix', + 'perf', + 'refactor', + 'revert', + 'style', + 'test', + ], + ] as [RuleConfigSeverity, RuleConfigCondition, string[]], + }, + prompt: { + questions: { + type: { + description: "Select the type of change that you're committing", + enum: { + feat: { + description: 'A new feature', + title: 'Features', + emoji: '✨', + }, + fix: { + description: 'A bug fix', + title: 'Bug Fixes', + emoji: 'πŸ›', + }, + docs: { + description: 'Documentation only changes', + title: 'Documentation', + emoji: 'πŸ“š', + }, + style: { + description: + 'Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)', + title: 'Styles', + emoji: 'πŸ’Ž', + }, + refactor: { + description: + 'A code change that neither fixes a bug nor adds a feature', + title: 'Code Refactoring', + emoji: 'πŸ“¦', + }, + perf: { + description: 'A code change that improves performance', + title: 'Performance Improvements', + emoji: 'πŸš€', + }, + test: { + description: 'Adding missing tests or correcting existing tests', + title: 'Tests', + emoji: '🚨', + }, + build: { + description: + 'Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)', + title: 'Builds', + emoji: 'πŸ› ', + }, + ci: { + description: + 'Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)', + title: 'Continuous Integrations', + emoji: 'βš™οΈ', + }, + chore: { + description: "Other changes that don't modify src or test files", + title: 'Chores', + emoji: '♻️', + }, + revert: { + description: 'Reverts a previous commit', + title: 'Reverts', + emoji: 'πŸ—‘', + }, + }, + }, + scope: { + description: + 'What is the scope of this change (e.g. component or file name)', + }, + subject: { + description: + 'Write a short, imperative tense description of the change', + }, + body: { + description: 'Provide a longer description of the change', + }, + isBreaking: { + description: 'Are there any breaking changes?', + }, + breakingBody: { + description: + 'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself', + }, + breaking: { + description: 'Describe the breaking changes', + }, + isIssueAffected: { + description: 'Does this change affect any open issues?', + }, + issuesBody: { + description: + 'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself', + }, + issues: { + description: 'Add issue references (e.g. "fix #123", "re #123".)', + }, + }, + }, +}; \ No newline at end of file