diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..0b1d1e8 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,10 @@ +[target.'cfg(target_os="linux")'] +rustflags = ["-C", "link-arg=-fuse-ld=mold"] + +[target.'cfg(target_os="windows")'] +rustflags = ["-C", "link-arg=-fuse-ld=lld"] + +# On Windows MSVC, statically link the C runtime so that the resulting EXE does +# not depend on the vcruntime DLL. +[target.'cfg(all(windows, target_env = "msvc"))'] +rustflags = ["-C", "target-feature=+crt-static"] diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..cdda8ab --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,27 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + + - package-ecosystem: "cargo" + directory: "/" # Location of package manifests + schedule: + interval: "monthly" + commit-message: + prefix: "chore(deps)" + groups: + cargo: + patterns: + - "*" + + - package-ecosystem: "github-actions" + # Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.) + directory: "/" + schedule: + interval: "monthly" + commit-message: + prefix: "chore(ci)" + include: "scope" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e66ecdf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: CI + +on: + push: + branches: + - dev + - main + pull_request: + branches: + - dev + - main + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + # Build the app on all supported platforms + build: + strategy: + matrix: + platform: [ubuntu-22.04] + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v4 + - name: Set minimal profile (Windows only) + if: matrix.platform == 'windows-latest' + run: rustup set profile minimal + - uses: Swatinem/rust-cache@v2 + with: + key: "${{matrix.platform}}" + - name: install packages (ubuntu) + if: matrix.platform == 'ubuntu-22.04' + run: sudo apt-get update && sudo apt-get -y --no-install-recommends install mold + - name: Build + run: cargo build --locked + + # We only need to run the checks on a single platform + checks: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + with: + key: ubuntu-22.04 + - name: install packages + run: sudo apt-get update && sudo apt-get -y --no-install-recommends install mold + # Checks begin here! + - run: cargo fmt --all -- --check + - run: cargo test --locked + - run: cargo clippy --locked --all-targets + # We care that the benchmarks build and run, not about their numeric output. + # To keep the CI a bit leaner, do this in the dev profile. + - run: cargo build --locked --all-targets diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml new file mode 100644 index 0000000..62f48dd --- /dev/null +++ b/.github/workflows/cleanup.yml @@ -0,0 +1,39 @@ +name: cleanup caches made by a branch +on: + pull_request: + types: + - closed + workflow_dispatch: + +jobs: + cleanup: + runs-on: ubuntu-latest + permissions: + # `actions:write` permission is required to delete caches + # See also: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id + actions: write + contents: read + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Cleanup + run: | + gh extension install actions/gh-actions-cache + + REPO=${{ github.repository }} + BRANCH=refs/pull/${{ github.event.pull_request.number }}/merge + + echo "Fetching list of cache key" + cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 ) + + ## Setting this to not fail the workflow while deleting cache keys. + set +e + echo "Deleting caches..." + for cacheKey in $cacheKeysForPR + do + gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + done + echo "Done" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9205e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*~ +*.swp +.temp + +# Added by cargo + +/target diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..10754f7 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "rust-lang.rust-analyzer", + "vadimcn.vscode-lldb", + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..5915432 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,45 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug executable 'qcpt'", + "cargo": { + "args": [ + "build", + "--bin=qcpt", + "--package=qcpt" + ], + "filter": { + "name": "qcpt", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug unit tests in executable 'qcpt'", + "cargo": { + "args": [ + "test", + "--no-run", + "--bin=qcpt", + "--package=qcpt" + ], + "filter": { + "name": "qcpt", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1dd34d2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,15 @@ +{ + "[typescript]": { + "editor.defaultFormatter": "vscode.typescript-language-features" + }, + "[html]": { + "editor.defaultFormatter": "vscode.html-language-features" + }, + "[css]": { + "editor.defaultFormatter": "vscode.css-language-features" + }, + "rust-analyzer.linkedProjects": [ + "./Cargo.toml" + ], + "rust-analyzer.showUnlinkedFileNotification": false +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..4c87a95 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "cargo", + "command": "build", + "problemMatcher": [ + "$rustc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "label": "rust: cargo build" + }, + { + "type": "cargo", + "command": "check", + "problemMatcher": [ + "$rustc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "label": "rust: cargo check" + }, + { + "type": "cargo", + "command": "clippy", + "problemMatcher": [ + "$rustc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "label": "rust: cargo clippy" + } + ] +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..4cdf94e --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "qcpt" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..9f1e956 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,34 @@ +[workspace] +members = [ + "qcpt" +] +resolver = "2" +package.version = "0.1.0" +package.edition = "2021" +package.authors = ["Ross Younger "] +package.license = "AGPL-3.0-or-later" + +[workspace.lints.rust] +dead_code = "warn" +elided_lifetimes_in_paths = "deny" +meta_variable_misuse = "deny" +missing_abi = "deny" +missing_copy_implementations = "deny" +missing_debug_implementations = "deny" +missing_docs = "warn" +non_ascii_idents = "deny" +single_use_lifetimes = "deny" +trivial_casts = "deny" +trivial_numeric_casts = "deny" +unsafe_code = "deny" +unsafe_op_in_unsafe_fn = "deny" +unreachable_pub = "deny" +# unused_crate_dependencies = "deny" # false positives +unused_extern_crates = "deny" +unused_lifetimes = "deny" +unused_results = "deny" +variant_size_differences = "deny" + +[workspace.lints.clippy] +pedantic = { level = "deny", priority = -1 } +missing_errors_doc = "allow" diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000..d0411d0 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,115 @@ +# git-cliff ~ default configuration file +# https://git-cliff.org/docs/configuration +# +# Lines starting with "#" are comments. +# Configuration options are organized into tables and keys. +# See documentation for more information on available options. + +[changelog] +# changelog header +header = """ +# Changelog\n +Notable changes to this project will be documented in this file.\n +(N.B. This file is autogenerated from the git commit logs.)\n +""" +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{% if version %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %}\ + ## [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | upper_first }} + {% for commit in commits + | filter(attribute="scope") + | sort(attribute="scope") %} + - *({{commit.scope}})* {{ commit.message | upper_first }} + {%- if commit.breaking %} + {% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}} + {%- endif -%} + {%- endfor -%} + {% raw %}\n{% endraw %}\ + {%- for commit in commits %} + {%- if commit.scope -%} + {% else -%} + - {{ commit.message | upper_first }} + {% if commit.breaking -%} + {% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}} + {% endif -%} + {% endif -%} + {% endfor -%} + {% raw %}\n{% endraw %}\ +{% endfor %}\n +""" +# template for the changelog footer +footer = """ + +""" +# remove the leading and trailing s +trim = true +# postprocessors +postprocessors = [ + { pattern = '', replace = "https://github.com/crazyscot/brot3" }, # replace repository URL +] + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = false +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + # Replace issue numbers + { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/issues/${2}))"}, + + # Check spelling of the commit with https://github.com/crate-ci/typos + # If the spelling is incorrect, it will be automatically fixed. + #{ pattern = '.*', replace_command = 'typos --write-changes -' }, + + # Refactor legacy quasi-conventional commit messages + { pattern = '\[(ui|engine|cli)\]', replace = 'feat(${1}):' }, + { pattern = '(cli|engine|ui):', replace = 'feat(${1}):' }, + { pattern = '\[bugfix\]', replace = 'fix:' }, + { pattern = '\[(chore|ci|feature|misc|refactor)\]', replace = '${1}:' }, +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "^feat", group = "๐Ÿš€ Features" }, + { message = "^fix|^bugfix", group = "๐Ÿ› Bug Fixes" }, + { message = "^doc", group = "๐Ÿ“š Documentation" }, + { message = "^perf", group = "โšก Performance" }, + { message = "^refactor", group = "๐Ÿšœ Refactor" }, + { message = "^style", group = "๐ŸŽจ Styling" }, + { message = "^test", group = "๐Ÿงช Testing" }, + { message = "^chore\\(release\\): prepare for", skip = true }, + { message = "^chore\\(release\\): update version", skip = true }, + { message = "^chore\\(ci\\)", skip = true }, + { message = "^chore\\(deps.*\\)", skip = true }, + { message = "^chore\\(pr\\)", skip = true }, + { message = "^chore\\(pull\\)", skip = true }, + { message = "^chore|^ci|^misc|^tidyup", group = "โš™๏ธ Miscellaneous Tasks" }, + { body = ".*security", group = "๐Ÿ›ก๏ธ Security" }, + { message = "^revert", group = "โ—€๏ธ Revert" }, + { message = "^cargo|^npm\\((deps|deps-dev)\\)|^internal|^menu.rs|^rust|^bump", skip = true }, + #{ message = "^.*:", group = "Other" }, # not useful +] +# protect breaking changes from being skipped due to matching a skipping commit_parser +protect_breaking_commits = false +# filter out the commits that are not matched by commit parsers +filter_commits = false +# regex for matching git tags +tag_pattern = "v[0-9].*" +# regex for skipping tags +skip_tags = "unreleased|0.1.0" +# regex for ignoring tags +# ignore_tags = "" +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "oldest" +# limit the number of commits included in the changelog. +# limit_commits = 42 diff --git a/qcpt/Cargo.toml b/qcpt/Cargo.toml new file mode 100644 index 0000000..7afe23f --- /dev/null +++ b/qcpt/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "qcpt" +description = "QCP transport low-level utility" +edition.workspace = true +authors.workspace = true +version.workspace = true +license.workspace = true +rust-version = "1.74.0" + +[dependencies] + diff --git a/qcpt/src/main.rs b/qcpt/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/qcpt/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}