From 27327c3e3fd3b431fd12499ef2154712e31ddbd8 Mon Sep 17 00:00:00 2001 From: Ali Sajid Imami <395482+AliSajid@users.noreply.github.com> Date: Tue, 28 May 2024 12:47:54 -0400 Subject: [PATCH] feat: add backend boilerplate Signed-off-by: Ali Sajid Imami <395482+AliSajid@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/bug_report.md | 39 +++ .github/ISSUE_TEMPLATE/feature_request.md | 27 +++ .github/workflows/.gitkeep | 0 .github/workflows/audit.yaml | 32 +++ .github/workflows/build_container.yaml | 137 +++++++++++ .github/workflows/ci.yaml | 127 ++++++++++ .github/workflows/code_coverage.yaml | 38 +++ .github/workflows/deploy_mdbook.yaml | 90 +++++++ .github/workflows/get_next_version.yaml | 58 +++++ .github/workflows/release.yaml | 181 ++++++++++++++ .github/workflows/shuttle_deploy.yaml | 20 ++ .gitleaksignore | 1 + .markdownlint.json | 16 ++ .markdownlintignore | 4 + .pre-commit-config.yaml | 151 ++++++++++++ .releaserc.yml | 28 +++ .reuse/dep5 | 62 +++++ .rustfmt.toml | 63 +++++ .secrets.baseline | 118 ++++++++++ .vale.ini | 41 ++++ .yamlfmt | 17 ++ .yamllint.yml | 17 ++ CODE_OF_CONDUCT.md | 140 +++++++++++ CONTRIBUTING.md | 151 ++++++++++++ Cargo.toml | 19 ++ Dockerfile | 58 +++++ Justfile | 24 ++ LICENSE-APACHE | 201 ++++++++++++++++ LICENSE-MIT | 21 ++ LICENSES/Apache-2.0.txt | 73 ++++++ LICENSES/CC0-1.0.txt | 121 ++++++++++ LICENSES/MIT.txt | 9 + about.toml | 23 ++ backend/.gitignore | 35 +++ backend/.gitkeep | 0 backend/Cargo.toml | 48 ++++ backend/README.md | 31 +++ backend/src/kaleidoscope/main.rs | 8 + backend/src/kaleidoscope_lib/lib.rs | 8 + bacon.toml | 89 +++++++ deny.toml | 275 ++++++++++++++++++++++ meta/licenses.hbs | 37 +++ nextest.toml | 91 +++++++ 43 files changed, 2729 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 .github/workflows/.gitkeep create mode 100644 .github/workflows/audit.yaml create mode 100644 .github/workflows/build_container.yaml create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/code_coverage.yaml create mode 100644 .github/workflows/deploy_mdbook.yaml create mode 100644 .github/workflows/get_next_version.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/shuttle_deploy.yaml create mode 100644 .gitleaksignore create mode 100644 .markdownlint.json create mode 100644 .markdownlintignore create mode 100644 .pre-commit-config.yaml create mode 100644 .releaserc.yml create mode 100644 .reuse/dep5 create mode 100644 .rustfmt.toml create mode 100644 .secrets.baseline create mode 100644 .vale.ini create mode 100644 .yamlfmt create mode 100644 .yamllint.yml create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 Cargo.toml create mode 100644 Dockerfile create mode 100644 Justfile create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT create mode 100644 LICENSES/Apache-2.0.txt create mode 100644 LICENSES/CC0-1.0.txt create mode 100644 LICENSES/MIT.txt create mode 100644 about.toml create mode 100644 backend/.gitignore delete mode 100644 backend/.gitkeep create mode 100644 backend/Cargo.toml create mode 100644 backend/README.md create mode 100644 backend/src/kaleidoscope/main.rs create mode 100644 backend/src/kaleidoscope_lib/lib.rs create mode 100644 bacon.toml create mode 100644 deny.toml create mode 100644 meta/licenses.hbs create mode 100644 nextest.toml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..d812965 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,39 @@ + + +--- +name: Bug report +about: Create a report to help us improve +title: "[BUG]" +labels: bug +assignees: CogDisResLab + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '…' +2. Click on '…' +3. Scroll down to '… +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Versions (please complete the following information):** + - OS: [for example: macos, linux, windows] + - OS Version / Distribution: [for example: 10.15.7, Ubuntu 20.04, Windows 10] + - Release Version [for example: 0.1.0] + +**Related Context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..38cf522 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,27 @@ + + +--- +name: Feature request +about: Suggest an idea for this project +title: "[FEATURE]" +labels: enhancement +assignees: CogDisResLab + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of the problem. For example, it is frustrating when […] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Relevant context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/.gitkeep b/.github/workflows/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml new file mode 100644 index 0000000..471c512 --- /dev/null +++ b/.github/workflows/audit.yaml @@ -0,0 +1,32 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +--- +name: Security Audit +on: + schedule: + - cron: 0 0 1,15 * * + push: + branches: + - "*" + paths: + - '**/Cargo.toml' + - '**/Cargo.lock' + workflow_dispatch: +jobs: + security_audit: + if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Install cargo-audit + uses: taiki-e/install-action@6261d093c5f01aa48722a4640a5b00a02a358aac # v2.33.7 + with: + tool: cargo-audit + - name: Security Audit + run: cargo audit diff --git a/.github/workflows/build_container.yaml b/.github/workflows/build_container.yaml new file mode 100644 index 0000000..ae5e732 --- /dev/null +++ b/.github/workflows/build_container.yaml @@ -0,0 +1,137 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +--- +name: Docker Image Generation +on: + workflow_call: + workflow_dispatch: + release: + types: + - created + - published + - prereleased + +concurrency: + group: docker + cancel-in-progress: false +env: + DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }} + DOCKER_REPOSITORY_NAME: ${{ vars.DOCKER_REPOSITORY_NAME }} + REPOSITORY_NAME: ${{ github.event.repository.name }} + COSIGN_RELEASE_VERSION: v2.2.3 + SOURCE_DATE_EPOCH: 0 +jobs: + docker-build-push: + runs-on: ubuntu-latest + permissions: + id-token: write + packages: write + steps: + - name: Checkout + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - name: Get Last Commit Date/Time for reproducible builds + run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV + - name: Generate Docker Metadata + id: meta + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 + with: + images: | + ${{env.DOCKER_REPOSITORY_NAME}}/${{env.REPOSITORY_NAME}} + ghcr.io/${{ github.repository}} + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + labels: | + org.opencontainers.image.licenses="MIT AND Apache-2.0" + - name: Debug Metadata + run: echo "${{ steps.meta.outputs.json }}" + - name: Setup Buildx + uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 + with: + install: true + buildkitd-flags: --debug + - name: Setup QEMU + uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 + with: + platforms: aarch64,amd64 + - name: Login to DockerHub + uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0 + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Login to GitHub Container Registry + uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GHCR_TOKEN }} + - name: Build and Push Docker Images + id: build + uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 + env: + SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }} + with: + context: . + push: true + provenance: true + annotations: ${{ steps.meta.outputs.annotations }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + - name: Debug Build + run: echo "${{join(steps.build.outputs.*, '\n')}}" + - name: Install cosign + uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0 + with: + cosign-release: ${{ env.COSIGN_RELEASE_VERSION }} + - name: Install Syft + uses: anchore/sbom-action/download-syft@e8d2a6937ecead383dfe75190d104edd1f9c5751 # v0.16.0 + with: + syft-version: v1.0.1 + - name: Sign and Push + env: + IMAGE_DIGEST: ${{ steps.build.outputs.digest }} + IMAGE_TAGS: ${{ steps.meta.outputs.tags }} + GITHUB_TOKEN: ${{ github.token }} + SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }} + run: | + for tag in ${IMAGE_TAGS}; do + image="${tag}@${IMAGE_DIGEST}" + original_name="sbom-${tag}.json" + sanitized_name=$(echo "$original_name" | sed 's|[/:]|_|g' | tr '_-' '-_') + echo "Signing the image: ${image}" + echo "Using the original name: $original_name" + echo "Using the sanitized name: $sanitized_name" + echo "Signing and pushing ${tag}@${IMAGE_DIGEST}" + cosign sign --yes ${image} + echo "Generating Software Bill of Materials for ${image}" + syft ${image} -o spdx-json=${sanitized_name} -v + echo "Attesting the Software Bill of Materials for ${image}" + cosign attest --type=spdxjson --yes --predicate ${sanitized_name} ${image} + echo "Done signing and pushing ${tag}@${IMAGE_DIGEST} with SBOM" + done + shell: bash + # - name: Verify Signatures + # env: + # IMAGE_DIGEST: ${{ steps.build.outputs.digest }} + # IMAGE_TAGS: ${{ steps.meta.outputs.tags }} + # GITHUB_TOKEN: ${{ github.token }} + # SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }} + # run: | + # for tag in ${IMAGE_TAGS}; do + # image="${tag}@${IMAGE_DIGEST}" + # echo "Verifying ${image}" + # cosign verify ${image} --certificate-identity-regexp="${{vars.COSIGN_CERTIFICATE_IDENTITY}}" --certificate-oidc-issuer-regexp="${{vars.COSIGN_CERTIFICATE_OIDC_ISSUER}}" + # echo "Verifying SBOM Attestation for ${image}" + # cosign verify-attestation ${image} --type=spdxjson --certificate-identity-regexp="${{vars.COSIGN_CERTIFICATE_IDENTITY}}" --certificate-oidc-issuer-regexp="${{vars.COSIGN_CERTIFICATE_OIDC_ISSUER}}" + # echo "Done verifying ${image}" + # done + # shell: bash diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..50fb34a --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,127 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +--- +name: Continuous integration +on: + push: + branches: + - 'main' + pull_request: + branches: + - main + types: + - closed + workflow_dispatch: +concurrency: + group: CI +env: + GIST_KEY: {{ dynamic-badge-gist }} # pragma: allowlist secret + RUST_BACKTRACE: 1 + MINIMUM_WAIT: 3 + MAXIMUM_WAIT: 10 +jobs: + ci: + runs-on: ${{matrix.os}}-latest + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) || github.event_name == 'workflow_dispatch' + outputs: + result: ${{steps.result.outputs.result}} + strategy: + fail-fast: false + matrix: + rust: + - stable + - beta + - nightly + - {{ msrv }} # MSRV + os: + - windows + - ubuntu + - macos + include: + - os: windows + logo: windows + - os: ubuntu + logo: ubuntu + - os: macos + logo: apple + - rust: {{ msrv }} # MSRV + label: msrv + - rust: stable + label: stable + - rust: beta + label: beta + - rust: nightly + label: nightly + steps: + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{matrix.rust}} + components: rustfmt, clippy + - name: Install nightly Rust + uses: dtolnay/rust-toolchain@nightly + with: + toolchain: nightly + components: rustfmt, clippy + - name: Cache dependencies + uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # v2.2.1 + - name: Cargo Build + run: cargo build --verbose + - name: Cargo Test + run: cargo test + - name: Cargo Format + run: cargo +nightly fmt --all -- --check + - name: Cargo Lint + run: cargo clippy -- -D warnings + - name: Wait before badge creation + uses: AliSajid/random-wait-action@v1.1.0 + with: + minimum: ${{env.MINIMUM_WAIT}} + maximum: ${{env.MAXIMUM_WAIT}} + - name: Create Awesome Badge - Success + uses: schneegans/dynamic-badges-action@5d424ad4060f866e4d1dab8f8da0456e6b1c4f56 # v1.6.0 + if: success() + with: + auth: ${{secrets.GIST_SECRET}} + gistID: ${{env.GIST_KEY}} + filename: ${{matrix.os}}-${{matrix.label}}.json + label: Build + namedLogo: ${{matrix.logo}} + message: Succeeded + color: green + - name: Create Awesome Badge - Failure + uses: schneegans/dynamic-badges-action@5d424ad4060f866e4d1dab8f8da0456e6b1c4f56 # v1.6.0 + if: failure() + with: + auth: ${{secrets.GIST_SECRET}} + gistID: ${{env.GIST_KEY}} + filename: ${{matrix.os}}-${{matrix.label}}.json + namedLogo: ${{matrix.logo}} + label: Build + message: Failed + isError: true + - name: Set Result + if: always() + id: result + run: echo "result=${{job.status}}" >> "$GITHUB_OUTPUT" + generate_code_coverage: + uses: ./.github/workflows/code_coverage.yaml + needs: [ci] + secrets: inherit # pragma: allowlist secret + generate_mdbook: + uses: ./.github/workflows/deploy_mdbook.yaml + needs: [ci] + secrets: inherit # pragma: allowlist secret + get-next-version: + uses: ./.github/workflows/get_next_version.yaml + needs: [ci] + secrets: inherit # pragma: allowlist secret + semantic-release: + needs: [ci, get-next-version] + if: ${{needs.get-next-version.outputs.new-release-published == 'true'}} + uses: ./.github/workflows/release.yaml + secrets: inherit # pragma: allowlist secret diff --git a/.github/workflows/code_coverage.yaml b/.github/workflows/code_coverage.yaml new file mode 100644 index 0000000..1c50d1e --- /dev/null +++ b/.github/workflows/code_coverage.yaml @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +--- +name: Code Coverage +on: + workflow_call: +jobs: + test: + name: Generate Coverage + runs-on: ubuntu-latest + container: + image: xd009642/tarpaulin:develop-nightly + options: --security-opt seccomp=unconfined + steps: + - name: Checkout repository + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + # Nightly Rust is required for cargo llvm-cov --doc. + - uses: dtolnay/rust-toolchain@nightly + with: + components: llvm-tools-preview + - uses: taiki-e/install-action@6261d093c5f01aa48722a4640a5b00a02a358aac # v2.33.7 + with: + tool: cargo-llvm-cov,nextest + - name: Collect coverage data (including doctests) + run: | + cargo llvm-cov --no-report nextest --config-file nextest.toml + cargo llvm-cov --no-report --doc + cargo llvm-cov report --doctests --lcov --output-path lcov.info + - name: Upload to codecov.io + uses: codecov/codecov-action@125fc84a9a348dbcf27191600683ec096ec9021c # v4.4.1 + with: + file: lcov.info + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + working-directory: . diff --git a/.github/workflows/deploy_mdbook.yaml b/.github/workflows/deploy_mdbook.yaml new file mode 100644 index 0000000..5b3d87a --- /dev/null +++ b/.github/workflows/deploy_mdbook.yaml @@ -0,0 +1,90 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +name: Book Deployment +on: + workflow_call: + outputs: + deployment_url: + description: "The vercel deployment url of the book" + value: ${{ jobs.deploy_book.outputs.deployment_url }} + +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + GITHUB_TOKEN: ${{ secrets.ACTIONS_PAT_GITHUB }} + BRANCH: ${{ github.ref_name }} + +jobs: + deploy_book: + runs-on: ubuntu-latest + outputs: + deployment_url: ${{ steps.output_deployment_url.outputs.deployment_url }} + steps: + - name: Checkout the Repository + uses: actions/checkout@v3 + - name: Decide Deployment Environment + id: deployment_environment + run: | + if [[ ${{ env.BRANCH }} == "main" ]]; then + echo "PROJECT_ENVIRONMENT=production" >> $GITHUB_ENV + else + echo "PROJECT_ENVIRONMENT=preview" >> $GITHUB_ENV + fi + - name: Setup NodeJS + uses: actions/setup-node@v3 + with: + node-version: '18' + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@master + id: rust-toolchain + with: + toolchain: stable + - name: Cache dependencies + uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # v2.2.1 + - name: Install cargo-binstall + uses: taiki-e/install-action@v2 + with: + tool: cargo-binstall + - name: Install dependencies + run: cargo binstall --log-level debug --no-confirm --locked mdbook mdbook-plantuml mdbook-inline-highlighting + - name: Install dependencies + run: pnpm install -g vercel@latest + - name: Populate Preview Variables + run: vercel pull --yes --environment=${{env.PROJECT_ENVIRONMENT}} --token=${{ env.VERCEL_TOKEN }} + - name: Build the Book + run: mdbook build guide + - name: Build for Vercel deployment -- Preview + if: env.PROJECT_ENVIRONMENT == 'preview' + run: vercel build --cwd guide/book -y -d --token=${{ env.VERCEL_TOKEN }} + - name: Build for Vercel deployment -- Production + if: env.PROJECT_ENVIRONMENT == 'production' + run: vercel build --cwd guide/book -y --prod -d --token=${{ env.VERCEL_TOKEN }} + - name: Deploy to Vercel -- Preview + if: env.PROJECT_ENVIRONMENT == 'preview' + run: vercel deploy --cwd guide/book --prebuilt --token=${{ env.VERCEL_TOKEN }} > deployment_url + - name: Deploy to Vercel -- Production + if: env.PROJECT_ENVIRONMENT == 'production' + run: vercel deploy --cwd guide/book --prod --prebuilt --token=${{ env.VERCEL_TOKEN }} > deployment_url + - name: Output Deployment URL + id: output_deployment_url + run: echo "deployment_url=$(cat deployment_url)" >> $GITHUB_OUTPUT diff --git a/.github/workflows/get_next_version.yaml b/.github/workflows/get_next_version.yaml new file mode 100644 index 0000000..6278db2 --- /dev/null +++ b/.github/workflows/get_next_version.yaml @@ -0,0 +1,58 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +--- +name: Next semantic-release version +on: + workflow_call: + outputs: + new-release-published: + description: Indicates whether a new release will be published. The value is a string, either 'true' or 'false'. + value: ${{ jobs.get-next-version.outputs.new-release-published }} +jobs: + get-next-version: + name: Get next release version + runs-on: ubuntu-latest + outputs: + new-release-published: ${{ steps.get-next-version.outputs.new-release-published }} + steps: + - name: Checkout + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + fetch-depth: 0 + persist-credentials: false + - name: Configure Node.js + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: lts/* + - name: Cache action npm dependencies + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + id: cache-node-modules + with: + path: ${{ runner.temp }}/.semantic-release-action_next-release-version/node_modules + key: | + semantic-release-action/next-release-version-${{ runner.os }}-node-${{ hashFiles('${{ github.action_path }}/package-lock.json') }} + - name: Install dependencies on cache miss + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: | + npm install -g semantic-release semantic-release-export-data + shell: bash + - name: Get next release version + id: get-next-version + env: + GITHUB_TOKEN: ${{secrets.ACTIONS_PAT_GITHUB}} + run: | + : calculate next semantic-release version + semantic-release \ + --dry-run \ + --plugins semantic-release-export-data \ + --verify-conditions semantic-release-export-data \ + --verify-release '' \ + --generate-notes semantic-release-export-data \ + --prepare '' \ + --publish '' \ + --success '' \ + --fail '' + shell: bash diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..c685517 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,181 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +--- +on: + workflow_call: + +name: Semantic Release +env: + RUST_BACKTRACE: 1 + SEMREL_RUST_VERSION: 2.1.53 +concurrency: + group: ${{ github.workflow }} +jobs: + build_application: + name: Build CLI ${{ matrix.build.target }} + runs-on: ${{ matrix.build.os }} + env: + CARGO: cargo + strategy: + matrix: + bin: + - {{project-name}} + build: + # alphabatized by target + - os: macOS-latest + target: aarch64-apple-darwin + cross: true + - os: ubuntu-latest + target: aarch64-unknown-linux-gnu + cross: true + - os: ubuntu-latest + target: aarch64-unknown-linux-musl + cross: true + - os: ubuntu-latest + target: i686-unknown-linux-gnu + cross: true + - os: ubuntu-latest + target: i686-unknown-linux-musl + cross: true + - os: macOS-latest + target: x86_64-apple-darwin + cross: false + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + cross: false + - os: ubuntu-latest + target: x86_64-unknown-linux-musl + cross: false + - os: ubuntu-latest + target: x86_64-pc-windows-gnu + cross: true + - os: ubuntu-latest + target: i686-pc-windows-gnu + cross: true + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - name: Install tree + if: runner.os == 'Linux' + run: sudo apt install tree + - name: Install build inputs + if: runner.os == 'Linux' && !matrix.build.cross + run: sudo apt install musl-tools mingw-w64 + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@master + id: rust-toolchain + with: + toolchain: stable + target: ${{ matrix.build.target }} + - name: Cache dependencies + uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # v2.2.1 + - name: Install cross + uses: taiki-e/install-action@v2 + with: + tool: cross + - name: Configure cross + if: matrix.build.cross + run: echo "CARGO=cross" >> "$GITHUB_ENV" + - name: Compile release binary + run: ${{ env.CARGO }} build --bin ${{ matrix.bin }} --release --target ${{ matrix.build.target }} --verbose + - name: Show generated binary + if: runner.os == 'Linux' + run: tree target/ + - name: Create release archive - windows + if: matrix.build.target == 'x86_64-pc-windows-gnu' || matrix.build.target == 'i686-pc-windows-gnu' + run: | + mkdir dist + cp target/${{ matrix.build.target }}/release/${{ matrix.bin }}.exe dist/${{ matrix.bin }}-${{ matrix.build.target }} + - name: Create release archive - non-windows + if: matrix.build.target != 'x86_64-pc-windows-gnu' && matrix.build.target != 'i686-pc-windows-gnu' + run: | + mkdir dist + cp target/${{ matrix.build.target }}/release/${{ matrix.bin }} dist/${{ matrix.bin }}-${{ matrix.build.target }} + - name: Create binary checksum + run: | + shasum --algorithm 256 \ + --binary ${{ matrix.bin }}-${{ matrix.build.target }} | tee ${{ matrix.bin }}-${{ matrix.build.target }}-SHA256SUM.txt + working-directory: ./dist + - name: Upload release artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.build.target }} + path: | + dist/${{ matrix.bin }}-${{ matrix.build.target }} + dist/${{ matrix.bin }}-${{ matrix.build.target }}-SHA256SUM.txt + if-no-files-found: error + retention-days: 1 + release: + name: Semantic Release + runs-on: ubuntu-latest + needs: build_application + outputs: + new_release_version: ${{steps.semantic.outputs.new_release_version}} + new_release_published: ${{steps.semantic.outputs.new_release_published}} + new_release_notes: ${{steps.semantic.outputs.new_release_notes}} + new_release_channel: ${{steps.semantic.outputs.new_release_channel}} + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + with: + fetch-depth: 0 + persist-credentials: false + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }} + fingerprint: ${{ secrets.GPG_SUBKEY_FINGERPRINT }} + trust_level: 5 + git_user_signingkey: true + git_commit_gpgsign: true + git_tag_gpgsign: false + git_committer_name: ${{ vars.GIT_AUTHOR_NAME }} + git_committer_email: ${{ vars.GIT_AUTHOR_EMAIL }} + - name: Test GPG Key Import + run: gpg --list-keys --keyid-format LONG + - name: Install dependencies + run: sudo apt install tree + - name: Install semantic-release-cargo + uses: taiki-e/install-action@v2 + with: + tool: semantic-release-cargo@${{env.SEMREL_RUST_VERSION}} + - name: Download release artifacts + uses: actions/download-artifact@v3 + with: + path: artifacts + - name: ls artifacts + run: tree ./artifacts + - name: Prepare GitHub Release artifacts + run: | + mkdir dist/ + mv -v artifacts/aarch64-apple-darwin dist/ + mv -v artifacts/aarch64-unknown-linux-gnu dist/ + mv -v artifacts/aarch64-unknown-linux-musl dist/ + mv -v artifacts/i686-unknown-linux-gnu dist/ + mv -v artifacts/i686-unknown-linux-musl dist/ + mv -v artifacts/x86_64-apple-darwin dist/ + mv -v artifacts/x86_64-unknown-linux-gnu dist/ + mv -v artifacts/x86_64-unknown-linux-musl dist/ + mv -v artifacts/x86_64-pc-windows-gnu dist/ + mv -v artifacts/i686-pc-windows-gnu dist/ + - name: Combine checksums + run: cat dist/**/*-SHA256SUM.txt | tee dist/SHA256SUMS.txt + - name: Install Conventional Commit preset + run: npm install conventional-changelog-conventionalcommits + - name: Semantic Release + uses: cycjimmy/semantic-release-action@61680d0e9b02ff86f5648ade99e01be17f0260a4 # v4.0.0 + id: semantic + with: + semantic_version: 22.0.3 + extra_plugins: | + @semantic-release/exec@6 + @semantic-release/git@10 + env: + GITHUB_TOKEN: ${{secrets.ACTIONS_PAT_GITHUB}} + CARGO_REGISTRY_TOKEN: ${{secrets.SEMREL_CRATES_IO}} + GIT_AUTHOR_NAME: ${{vars.GIT_AUTHOR_NAME}} + GIT_AUTHOR_EMAIL: ${{vars.GIT_AUTHOR_EMAIL}} diff --git a/.github/workflows/shuttle_deploy.yaml b/.github/workflows/shuttle_deploy.yaml new file mode 100644 index 0000000..67dbc90 --- /dev/null +++ b/.github/workflows/shuttle_deploy.yaml @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +--- +name: Deploy to Shuttle +on: + workflow_call: + +jobs: + shuttle-deployment: + name: Shuttle Deployment + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: shuttle-hq/deploy-action@main + with: + deploy-key: ${{ secrets.SHUTTLE_DEPLOY_KEY }} diff --git a/.gitleaksignore b/.gitleaksignore new file mode 100644 index 0000000..5d29c0b --- /dev/null +++ b/.gitleaksignore @@ -0,0 +1 @@ +.github/workflows/ci.yaml:generic-api-key:15 diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..2510c11 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,16 @@ +{ + "MD003": { + "style": "atx" + }, + "MD007": { + "indent": 2 + }, + "MD013": false, + "MD024": false, + "MD033": false, + "MD041": false, + "default": true, + "link-fragments": false, + "no-hard-tabs": true, + "whitespace": false +} diff --git a/.markdownlintignore b/.markdownlintignore new file mode 100644 index 0000000..e19d7c0 --- /dev/null +++ b/.markdownlintignore @@ -0,0 +1,4 @@ +^LICENSE +.github/**/* +meta/LICENSE-HEADER +guide/src/SUMMARY.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..f507de8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,151 @@ +--- +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: CC0-1.0 +repos: + - repo: local + hooks: + - id: fmt + name: Rust format + entry: cargo +nightly fmt --all + language: system + types: [rust] + files: \.rs$ + pass_filenames: false + - id: clippy + name: Run clippy linter + entry: cargo +nightly clippy --all-targets --all-features -- -D warnings + language: system + types: [rust] + files: \.rs$ + pass_filenames: false + - id: cargo-check + name: Run cargo check + entry: cargo +nightly check --all-targets --all-features + language: system + types: [rust] + files: \.rs$ + pass_filenames: false + - id: cargo-about-json + name: Generate list of licenses in JSON + entry: scripts/generate_about_json.sh + language: script + types_or: [file, rust] + files: "Cargo.toml$" + pass_filenames: false + - id: cargo-about-md + name: Generate list of licenses in Markdown + entry: scripts/generate_about_md.sh meta/licenses.hbs + language: script + types_or: [file, rust] + files: "Cargo.toml$" + pass_filenames: false + - id: cargo-toml-lint + name: Check Cargo.toml + entry: cargo-toml-lint + language: system + types_or: [file, rust] + files: "Cargo.toml$" + pass_filenames: true + - id: vale-lint + name: Run Vale linter + entry: vale + language: system + types: [markdown] + files: "^(README.md|CONTRIBUTING.md|CODE_OF_CONDUCT.md|guide/src/.*.md)$" + - repo: https://github.com/commitizen-tools/commitizen + rev: v3.15.0 + hooks: + - id: commitizen + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-json + exclude: ".vscode/.*json" + - id: check-merge-conflict + - id: no-commit-to-branch + args: + - --branch + - main + - --branch + - next + - id: check-shebang-scripts-are-executable + - id: check-toml + - id: check-xml + - id: check-yaml + - id: end-of-file-fixer + exclude: ".*licenses.*\\.(md|hbs)" + - id: mixed-line-ending + args: + - --fix=no + - id: pretty-format-json + exclude: ".vscode/.*json" + args: + - --indent=4 + - --autofix + - --no-ensure-ascii + - id: trailing-whitespace + exclude: "licenses_report.md" + args: + - --markdown-linebreak-ext=md + - repo: https://github.com/compilerla/conventional-pre-commit + rev: v3.1.0 + hooks: + - args: + - build + - chore + - ci + - docs + - feat + - fix + - perf + - refactor + - revert + - style + - test + - bump + id: conventional-pre-commit + stages: + - commit-msg + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.5.5 + hooks: + - id: forbid-crlf + - id: remove-crlf + - id: forbid-tabs + - id: remove-tabs + - repo: https://github.com/google/yamlfmt + rev: v0.11.0 + hooks: + - id: yamlfmt + exclude: ".github/workflows/.*\\.ya?ml" + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.39.0 + hooks: + - id: markdownlint + args: + - --ignore + - CHANGELOG.md + - repo: https://github.com/Yelp/detect-secrets + rev: v1.4.0 + hooks: + - id: detect-secrets + args: + - "--baseline" + - ".secrets.baseline" + exclude: "meta/licenses.*" + - repo: https://github.com/sirosen/texthooks + rev: 0.6.4 + hooks: + - id: fix-smartquotes + exclude: "licenses_report.json" + - id: fix-ligatures + - id: forbid-bidi-controls + - repo: https://github.com/zricethezav/gitleaks + rev: v8.18.2 + hooks: + - id: gitleaks + - repo: https://github.com/fsfe/reuse-tool + rev: v3.0.1 + hooks: + - id: reuse diff --git a/.releaserc.yml b/.releaserc.yml new file mode 100644 index 0000000..60873c9 --- /dev/null +++ b/.releaserc.yml @@ -0,0 +1,28 @@ +--- +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: CC0-1.0 +branches: + - v[0-9]+.[0-9]+.[0-9]+ + - main + - name: next + prerelease: true +plugins: + - "@semantic-release/commit-analyzer" + - - "@semantic-release/changelog" + - changelogFile: CHANGELOG.md + - - "@semantic-release/release-notes-generator" + - preset: conventionalcommits + - - "@semantic-release/github" + - assets: + - "dist/*" + - - "@semantic-release/exec" + - verifyConditionsCmd: ~/.cargo/bin/semantic-release-cargo -v verify-conditions + prepareCmd: ~/.cargo/bin/semantic-release-cargo -v prepare ${nextRelease.version} + publishCmd: ~/.cargo/bin/semantic-release-cargo -v publish + - - "@semantic-release/git" + - assets: + - Cargo.toml + - Cargo.lock + - CHANGELOG.md + message: "chore(release): ${nextRelease.version} [skip ci]" diff --git a/.reuse/dep5 b/.reuse/dep5 new file mode 100644 index 0000000..9e5ab18 --- /dev/null +++ b/.reuse/dep5 @@ -0,0 +1,62 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: kaleidoscope +Upstream-Contact: Ali Sajid Imami +Source: https://github.com/AliSajid/Kaleidoscope + +# Sample paragraph, commented out: +# +# Files: src/* +# Copyright: $YEAR $NAME <$CONTACT> +# License: ... + +Files: .gitignore +Copyright: 2023 - 2024 Cognitive Disorders Research Lab +License: CC0-1.0 + +Files: guide/.gitignore +Copyright: 2023 - 2024 Cognitive Disorders Research Lab +License: CC0-1.0 + +Files: .gitleaksignore +Copyright: 2023 - 2024 Cognitive Disorders Research Lab +License: CC0-1.0 + +Files: .markdownlintignore +Copyright: 2023 - 2024 Cognitive Disorders Research Lab +License: CC0-1.0 + +Files: .markdownlint.json +Copyright: 2023 - 2024 Cognitive Disorders Research Lab +License: CC0-1.0 + +Files: Cargo.lock +Copyright: 2023 - 2024 Cognitive Disorders Research Lab +License: MIT AND Apache-2.0 + +Files: .secrets.baseline +Copyright: 2023 - 2024 Cognitive Disorders Research Lab +License: CC0-1.0 + +Files: .vscode/*.json +Copyright: 2023 - 2024 Cognitive Disorders Research Lab +License: CC0-1.0 + +Files: licenses_report.json +Copyright: 2023 - 2024 Cognitive Disorders Research Lab +License: Apache-2.0 AND MIT + +Files: .gitpod.Dockerfile +Copyright: 2023 - 2024 Cognitive Disorders Research Lab +License: CC0-1.0 + +Files: meta/vale-styles/config/**/*.txt +Copyright: 2023 - 2024 Cognitive Disorders Research Lab +License: CC0-1.0 + +Files: CHANGELOG.md +Copyright: 2023 - 2024 Cognitive Disorders Research Lab +License: CC0-1.0 + +Files: renovate.json +Copyright: 2023 - 2024 Cognitive Disorders Research Lab +License: MIT AND Apache-2.0 diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..8799a82 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,63 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: CC0-1.0 + +# Personal configuration for the `rustfmt` tool. + +# Stable options as of v1.6.0 + +## Use the 2021 edition of Rust +edition = "2021" + +## Use the unix style line endings +newline_style = "Auto" + +## Ensure if/else and let/else blocks are always on new lines +single_line_if_else_max_width = 0 +single_line_let_else_max_width = 0 + +## Use field-init shorthand +use_field_init_shorthand = true + +## Use the `?` instead of `try!` +use_try_shorthand = true + +# Unstable options as of v1.6.0 + +## Enforce colored output +color = "Always" + +## Configure comments +wrap_comments = true +comment_width = 120 +normalize_comments = true + +## Allow aligning of Enum Variants +enum_discrim_align_threshold = 20 + +## Format code in Doc Comments +doc_comment_code_block_width = 80 +format_code_in_doc_comments = true + +## Enforce string length limits +format_strings = true + +## Imports Formatting +imports_indent = "Block" +imports_layout = "Vertical" +imports_granularity = "Crate" +reorder_imports = true +group_imports = "StdExternalCrate" + +## Styling +indent_style = "Block" + +## Impl styles +reorder_impl_items = true + +## Module reordering +reorder_modules = true + +## Struct formating +struct_field_align_threshold = 20 +struct_lit_single_line = true diff --git a/.secrets.baseline b/.secrets.baseline new file mode 100644 index 0000000..fdc5557 --- /dev/null +++ b/.secrets.baseline @@ -0,0 +1,118 @@ +{ + "version": "1.4.0", + "plugins_used": [ + { + "name": "ArtifactoryDetector" + }, + { + "name": "AWSKeyDetector" + }, + { + "name": "AzureStorageKeyDetector" + }, + { + "name": "Base64HighEntropyString", + "limit": 4.5 + }, + { + "name": "BasicAuthDetector" + }, + { + "name": "CloudantDetector" + }, + { + "name": "DiscordBotTokenDetector" + }, + { + "name": "GitHubTokenDetector" + }, + { + "name": "HexHighEntropyString", + "limit": 3.0 + }, + { + "name": "IbmCloudIamDetector" + }, + { + "name": "IbmCosHmacDetector" + }, + { + "name": "JwtTokenDetector" + }, + { + "name": "KeywordDetector", + "keyword_exclude": "" + }, + { + "name": "MailchimpDetector" + }, + { + "name": "NpmDetector" + }, + { + "name": "PrivateKeyDetector" + }, + { + "name": "SendGridDetector" + }, + { + "name": "SlackDetector" + }, + { + "name": "SoftlayerDetector" + }, + { + "name": "SquareOAuthDetector" + }, + { + "name": "StripeDetector" + }, + { + "name": "TwilioKeyDetector" + } + ], + "filters_used": [ + { + "path": "detect_secrets.filters.allowlist.is_line_allowlisted" + }, + { + "path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies", + "min_level": 2 + }, + { + "path": "detect_secrets.filters.heuristic.is_indirect_reference" + }, + { + "path": "detect_secrets.filters.heuristic.is_likely_id_string" + }, + { + "path": "detect_secrets.filters.heuristic.is_lock_file" + }, + { + "path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string" + }, + { + "path": "detect_secrets.filters.heuristic.is_potential_uuid" + }, + { + "path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign" + }, + { + "path": "detect_secrets.filters.heuristic.is_sequential_string" + }, + { + "path": "detect_secrets.filters.heuristic.is_swagger_file" + }, + { + "path": "detect_secrets.filters.heuristic.is_templated_secret" + }, + { + "path": "detect_secrets.filters.regex.should_exclude_file", + "pattern": [ + "Cargo.lock" + ] + } + ], + "results": {}, + "generated_at": "2024-02-02T18:28:35Z" +} diff --git a/.vale.ini b/.vale.ini new file mode 100644 index 0000000..cae83bd --- /dev/null +++ b/.vale.ini @@ -0,0 +1,41 @@ +; SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +; +; SPDX-License-Identifier: CC0-1.0 + +StylesPath = "meta/vale-styles/" + +MinAlertLevel = suggestion + +Vocab = Custom + +Packages = Google, proselint, write-good, alex, Readability + +[*.md] +BasedOnStyles = Vale, proselint, write-good, alex, Readability, Google + +Google.Contractions = NO +Google.Headings = NO +Google.Parens = NO +Google.We = NO + +write-good.E-Prime = OFF +write-good.Passive = OFF +write-good.So = OFF +write-good.TooWordy = OFF +write-good.Weasel = OFF + +Readability.AutomatedReadability = 12 +Readability.ColemanLiau = 12 +Readability.FleschKincaid = 12 +Readability.FleschReadingEase = 50 +Readability.GunningFog = 15 +Readability.LIX = 40 +Readability.SMOG = 12 + +proselint.Very = OFF + +alex.Condescending = OFF +alex.ProfanityUnlikely = OFF + + +[CHANGELOG.md] diff --git a/.yamlfmt b/.yamlfmt new file mode 100644 index 0000000..3fc6bf1 --- /dev/null +++ b/.yamlfmt @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: CC0-1.0 +--- +line_ending: "lf" +doublestar: true +include: + - .github/**/*.yml + - .pre-commit-config.yaml + - .releaserc.yml + - .yamlfmt +formatter: + type: basic + include_document_start: true + line_ending: "lf" + max_line_length: 150 + indent: 4 diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..387e07c --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,17 @@ +--- +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: CC0-1.0 +extends: default +rules: + # 80 chars should be enough, but don't fail if a line is longer + line-length: + max: 150 + level: warning + truthy: + check-keys: false + indentation: + spaces: 4 + indent-sequences: true + comments: + min-spaces-from-content: 1 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..3171d19 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,140 @@ + + + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[INSERT CONTACT METHOD]. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..dbbc334 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,151 @@ + + + +# Contributing to Kaleidoscope + + +Thank you for taking your time to contribute to this project! Your efforts are greatly appreciated. ❤️ + + +We welcome and encourage all types of contributions. Please see the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. Following the contribution guidelines makes it a lot easier for the maintainers and smooth out the experience for all involved. The community looks forward to your contributions. + +If you like the project, but just don't have time to contribute, that's fine. You can still support the project and show your appreciation in other ways, which we also appreciate: + +- Star the project +- Tweet about it +- Cite the project in your publications if you found it helpful +- Refer this project in your project's README +- Mention the project at local meetups and tell your friends/colleagues + + +## Table of Contents + +- [I Have a Question](#i-have-a-question) +- [I Want To Contribute](#i-want-to-contribute) + - [Reporting Bugs](#reporting-bugs) + - [Suggesting Enhancements](#suggesting-enhancements) + - [Your First Code Contribution](#your-first-code-contribution) + - [Improving The Documentation](#improving-the-documentation) +- [Style Guides](#style-guides) + - [Commit Messages](#commit-messages) +- [Join The Project Team](#join-the-project-team) + + + +## I Have a Question + +Before you ask a question, it's best to search for existing [Issues](https://github.com/CogDisResLab/kaleidoscope/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It's also advisable to search the internet for answers first. + +If you then still feel the need to ask a question and need clarification, we recommend the following: + +- Open an [Issue](https://github.com/CogDisResLab/kaleidoscope/issues/new). +- Provide as much context as you can about what you're running into. +- Provide project and platform versions (`rustc -V`, etc), depending on what seems relevant. + +We then take care of the issue as soon as possible. + +## I Want To Contribute + +### Legal Notice + +When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license. + + +This project is dual-licensed under [MIT](LICENSE-MIT) and [Apache 2.0](LICENSE-APACHE). When you submit changes, your submissions are understood to be under the same [MIT](LICENSE-MIT) and [Apache 2.0](LICENSE-APACHE) that covers the project. Feel free to contact the maintainers if that's a concern. + + +### Reporting Bugs + + +#### Before Submitting a Bug Report + +A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible. + +- Make sure that you are using the latest version. +- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (If you are looking for support, you might want to check [this section](#i-have-a-question)). +- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/CogDisResLab/kaleidoscope/issues?q=label%3Abug). +- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue. +- Collect information about the bug: + - Stack trace (Traceback). We use RUST_BACKTRACE=1 to get a full stack trace. + - OS, Platform and Version (Windows, Linux, macOS, x86, ARM) + - Version of Rust, Cargo, and other environment components if applicable + - Possibly your input and the output + - Can you reliably reproduce the issue? And can you also reproduce it with older versions? + + +#### How Do I Submit a Good Bug Report? + + +We use GitHub issues to track bugs and errors. If you run into an issue with the project: + +- Open an [Issue](https://github.com/CogDisResLab/kaleidoscope/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.) +- Explain the behavior you would expect and the actual behavior. +- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case. +- Provide the information you collected in the previous section. + +Once it's filed: + +- The project team will label the issue accordingly. +- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced. +- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution). + + +### Suggesting Enhancements + +This section guides you through submitting an enhancement suggestion for Gainful Key, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions. + + +#### Before Submitting an Enhancement + +- Make sure that you are using the latest version. +- Perform a [search](https://github.com/CogDisResLab/kaleidoscope/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. +- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library. + + +#### How Do I Submit a Good Enhancement Suggestion? + +Enhancement suggestions are tracked as [GitHub issues](https://github.com/CogDisResLab/kaleidoscope/issues). + +- Use a **clear and descriptive title** for the issue to identify the suggestion. +- Provide a **step-by-step description of the suggested enhancement** in as many details as possible. +- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you. +- You may want to **include screenshots and animated GIFs** which help demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macos and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. +- **Explain why this enhancement would be useful** to most `aaprop` users. You may also want to point out the other projects that solved it better and which could serve as inspiration. + +### Your First Code Contribution + + +### Improving The Documentation + + +## Style Guides + +We use `rustfmt`, `clippy` and `cargo check` to ensure a consistent code style. We also use `cargo test` to ensure that all tests pass. Please do not allow specific `clippy` lints without discussion with the team first. + +### Commit Messages + +The project adheres to the Conventional Commits specification for commit messages, which enhances readability and ease of understanding when navigating through the project history and serves as the basis for generating the Gainful Key change log. + +## Join The Project Team + +Please [open an issue](https://github.com/CogDisResLab/kaleidoscope/issues) to let the team know that of your interest in joining, and we can discuss the details in the issue. + + +## Attribution + + + +This guide is based on the **contributing-gen**. [Make your own](https://github.com/bttger/contributing-gen) + + diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..48474f2 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +[workspace] +members = ["backend"] +resolver = '2' + +[profile.release] +opt-level = 'z' # Optimize for size +lto = true # Enable link-time optimization +codegen-units = 1 # Compile the whole crate at once +panic = "abort" # Abort on panic +strip = "symbols" # Strip debug symbols + +[profile.dev] +opt-level = 1 +debug = true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a3f95df --- /dev/null +++ b/Dockerfile @@ -0,0 +1,58 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +# This Dockerfile is used to build a Docker image for the aaprop project +# The image is built in two stages: +# 1. The first stage uses the official Rust image as the builder image +# It builds the Rust project and creates a binary +# 2. The second stage uses the official Debian image as the base image +# It copies the binary from the builder image and sets it as the entry point of the container + +# Use the official Rust image as the builder image +# Use the 1.75 version of the Rust image since it's the MSRV (Minimum Supported Rust Version) for the aaprop project +FROM rust:1.75.0 as builder + +# Set the working directory in the builder image to /usr/src +WORKDIR /usr/src + +# Create a new Rust project named aaprop +RUN USER=root cargo new --lib kaleidoscope + +# Change the working directory to the aaprop directory +WORKDIR /usr/src/kaleidoscope + +# Create the appropriate directory structure for the first build +RUN mkdir -p src/kaleidoscope_lib && mv -v src/lib.rs src/kaleidoscope_lib/lib.rs + +# Copy the Cargo.toml and Cargo.lock files to the aaprop directory +COPY Cargo.toml Cargo.lock ./ + +# Build the Rust project +# This step is done separately to take advantage of Docker's layer caching +# Any changes in the source code will not invalidate the cached dependencies +RUN cargo build --lib --no-default-features --release + +# Remove the auto-generated main.rs file +# This file will be replaced with the actual source code +RUN rm -rfv src/* + +# Remove the auto-generated binary and dependencies +# These will be replaced with the actual binary and dependencies +RUN rm -rfv target/release/deps/kaleidoscope* + +# Add the actual source code to the src directory +ADD src src + +# Build the Rust project with the actual source code +RUN cargo build --features standalone --no-default-features --release --locked + +# Use the official distroless image as the base image +FROM gcr.io/distroless/cc-debian12 + +# Copy the binary from the builder image to the base image +COPY --from=builder /usr/src/kaleidoscope/target/release/kaleidoscope /usr/local/bin/kaleidoscope + +# Change the user to a non-root user for security +USER 1000 diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..66d96de --- /dev/null +++ b/Justfile @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +# Rebuild project when rs and toml files change +watch: + just build + cargo watch -c -i "*.rs" -i "*.toml" -s "just build" + +# Pull out rust and toml code fences into their files +build: + cargo build + +# Run bacon +bacon: + bacon + +# make-compatible bootstrap +deps: + cargo install cargo-binstall + cargo binstall --locked bacon \ + cargo-watch just mdbook mdbook-inline-highlighting \ + mdbook-toc mdbook-plantuml diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..77eb057 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2022 Cognitive Disorder Research Laboratory + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..054fbc6 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/LICENSES/Apache-2.0.txt b/LICENSES/Apache-2.0.txt new file mode 100644 index 0000000..137069b --- /dev/null +++ b/LICENSES/Apache-2.0.txt @@ -0,0 +1,73 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + +To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/LICENSES/CC0-1.0.txt b/LICENSES/CC0-1.0.txt new file mode 100644 index 0000000..0e259d4 --- /dev/null +++ b/LICENSES/CC0-1.0.txt @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000..2071b23 --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/about.toml b/about.toml new file mode 100644 index 0000000..9c4e1b1 --- /dev/null +++ b/about.toml @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +# Accepted licesnes by default +accepted = ["Apache-2.0", "MIT"] +targets = [ + "aarch64-unknown-linux-gnu", + "aarch64-unknown-linux-musl", + "i686-unknown-linux-gnu", + "i686-unknown-linux-musl", + "x86_64-unknown-linux-gnu", + "x86_64-unknown-linux-musl" +] + +# Do not ignore any dependencies +ignore-build-dependencies = false +ignore-dev-dependencies = false +ignore-transitive-dependencies = false + +# Try to resolve any time clearlydefined.io marks something as NOASSERTION +filter-noassertion = true diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..aaf6142 --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,35 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: CC0-1.0 + +# Created by https://www.toptal.com/developers/gitignore/api/rust +# Edit at https://www.toptal.com/developers/gitignore?templates=rust + +### Rust ### +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# End of https://www.toptal.com/developers/gitignore/api/rust + +!scripts/ + +guide/book + +meta/vale-styles/**/* +!meta/vale-styles/config + + +# Special Ignore File +package_version_to_delete diff --git a/backend/.gitkeep b/backend/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/backend/Cargo.toml b/backend/Cargo.toml new file mode 100644 index 0000000..bd614dd --- /dev/null +++ b/backend/Cargo.toml @@ -0,0 +1,48 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +[package] +name = "kaleidoscope" +version = "1.0.0-next.1" +edition = "2021" +readme = "README.md" +description = "" +rust-version = "1.75.0" +repository = "https://github.com/CogDisResLab/kaleidoscope" +license = "MIT OR Apache-2.0" + +[lib] +name = "kaleidoscope_lib" +path = "src/kaleidoscope_lib/lib.rs" +crate-type = ["lib"] + +[[bin]] +name = "kaleidoscope" +path = "src/kaleidoscope/main.rs" + +[dependencies] +clap = { version = "4", features = ["string", "unicode", "derive"] } +anyhow = { version = "1", features = ["backtrace"] } +color-eyre = "0.6" + +[dev-dependencies] +rstest = "0.19" + +### Specify / Override the specific lints + +[lints.rustdoc] +broken_intra_doc_links = "deny" +missing_docs = "forbid" +invalid_rust_codeblocks = "deny" +redundant_explicit_links = "deny" + +[lints.rust] +unsafe_code = "forbid" + +[lints.clippy] +enum_glob_use = "deny" +pedantic = "deny" +nursery = "deny" +unwrap_used = "deny" diff --git a/backend/README.md b/backend/README.md new file mode 100644 index 0000000..06729b4 --- /dev/null +++ b/backend/README.md @@ -0,0 +1,31 @@ + + +# Kaleidoscope + +![GitHub Release (w/pre-release)](https://img.shields.io/github/v/release/CogDisResLab/kaleidoscope?include_prereleases&logo=semantic-release) +![GitHub Release](https://img.shields.io/github/v/release/CogDisResLab/kaleidoscope?logo=semantic-release) +[![Continuous integration](https://github.com/CogDisResLab/kaleidoscope/actions/workflows/ci.yaml/badge.svg)](https://github.com/CogDisResLab/kaleidoscope/actions/workflows/ci.yaml) +[![Security Audit](https://github.com/CogDisResLab/kaleidoscope/actions/workflows/audit.yaml/badge.svg?branch=main)](https://github.com/CogDisResLab/kaleidoscope/actions/workflows/audit.yaml) + +[![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/CogDisResLab/kaleidoscope) +![GitHub issues](https://img.shields.io/github/issues/CogDisResLab/kaleidoscope) +![REUSE Compliance](https://img.shields.io/reuse/compliance/github.com%2FCogDisResLab%2Faaprop) + +A repository of gene-specific data for ease of use and access + +## Build Status + +| | Stable | Beta | Nightly | MSRV (1.75.0) | +| ------- | ------ | ---- | ------- | ---- | +| Linux | ![Ubuntu x Stable Rust](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/CogDisResLab/9b4eb5e54be618d13eee7e67ae220b56/raw/ubuntu-stable.json) | ![Ubuntu x Beta Rust](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/CogDisResLab/9b4eb5e54be618d13eee7e67ae220b56/raw/ubuntu-beta.json) | ![Ubuntu x Nightly Rust](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/CogDisResLab/9b4eb5e54be618d13eee7e67ae220b56/raw/ubuntu-nightly.json) | ![Ubuntu x MSRV Rust](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/CogDisResLab/9b4eb5e54be618d13eee7e67ae220b56/raw/ubuntu-msrv.json) | +| Windows | ![Windows x Stable Rust](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/CogDisResLab/9b4eb5e54be618d13eee7e67ae220b56/raw/windows-stable.json) | ![Windows x Beta Rust](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/CogDisResLab/9b4eb5e54be618d13eee7e67ae220b56/raw/windows-beta.json) | ![Windows x Nightly Rust](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/CogDisResLab/9b4eb5e54be618d13eee7e67ae220b56/raw/windows-nightly.json) | ![Windows x MSRV Rust](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/CogDisResLab/9b4eb5e54be618d13eee7e67ae220b56/raw/windows-msrv.json) | +| macos | ![macos x Stable Rust](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/CogDisResLab/9b4eb5e54be618d13eee7e67ae220b56/raw/macos-stable.json) | ![macos x Beta Rust](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/CogDisResLab/9b4eb5e54be618d13eee7e67ae220b56/raw/macos-beta.json) | ![macos x Nightly Rust](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/CogDisResLab/9b4eb5e54be618d13eee7e67ae220b56/raw/macos-nightly.json) | ![macos x MSRV Rust](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/CogDisResLab/9b4eb5e54be618d13eee7e67ae220b56/raw/macos-msrv.json) | + +## Current Status + +The current status of the project is ... diff --git a/backend/src/kaleidoscope/main.rs b/backend/src/kaleidoscope/main.rs new file mode 100644 index 0000000..2caf757 --- /dev/null +++ b/backend/src/kaleidoscope/main.rs @@ -0,0 +1,8 @@ +// SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +// +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +fn main() { + println!("Hello, KALEIDOSCOPE!"); +} diff --git a/backend/src/kaleidoscope_lib/lib.rs b/backend/src/kaleidoscope_lib/lib.rs new file mode 100644 index 0000000..d0132c4 --- /dev/null +++ b/backend/src/kaleidoscope_lib/lib.rs @@ -0,0 +1,8 @@ +// SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +// +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +pub fn lib_function() { + println!("Hello, KALEIDOSCOPE_LIB!"); +} diff --git a/bacon.toml b/bacon.toml new file mode 100644 index 0000000..c209208 --- /dev/null +++ b/bacon.toml @@ -0,0 +1,89 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +default_job = "clippy" +summary = true +wrap = true + +[jobs.check] +command = ["cargo", "check", "--color", "always"] +need_stdout = false + +[jobs.check-all] +command = ["cargo", "check", "--all-targets", "--color", "always"] +need_stdout = false + +[jobs.clippy] +command = [ + "cargo", + "+nightly", + "clippy", + "--color", + "always", + "--", + "-W", + "clippy::pedantic", + "-W", + "clippy::nursery", + "-W", + "clippy::unwrap_used", + "-W", + "clippy::expect_used", +] +need_stdout = false +apply_gitignore = false + +# This job lets you run +# - all tests: bacon test +# - a specific test: bacon test -- config::test_default_files +# - the tests of a package: bacon test -- -- -p config +[jobs.test] +command = [ + "cargo", + "test", + "--", + "--color", + "always", # https://github.com/Canop/bacon/issues/124 +] +need_stdout = true + +[jobs.doc] +command = ["cargo", "doc", "--color", "always", "--no-deps"] +need_stdout = false +on_success = "back" + +# If the doc compiles, then it opens in your browser and bacon switches +# to the previous job +[jobs.doc-open] +command = ["cargo", "doc", "--color", "always", "--no-deps", "--open"] +need_stdout = false +on_success = "back" # so that we don't open the browser at each change + +# Audit your dependencies for security vulnerabilities +[jobs.audit] +command = ["cargo", "audit", "--color", "always"] +need_stdout = true + +# This parameterized job runs the example of your choice, as soon +# as the code compiles. +# Call it as +# bacon ex -- my-example +[jobs.ex] +command = ["cargo", "run", "--color", "always", "--example"] +allow_warnings = true +need_stdout = true + +# You may define here keybindings that would be specific to +# a project, for example a shortcut to launch a specific job. +# Shortcuts to internal functions (scrolling, toggling, etc.) +# should go in your personal global prefs.toml file instead. +[keybindings] +# alt-m = "job:my-job" +ctrl-c = "job:check-all" +a = "job:audit" +t = "job:test" +d = "job:doc" +o = "job:doc-open" +c = "job:clippy" diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..4b4f7e0 --- /dev/null +++ b/deny.toml @@ -0,0 +1,275 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +# This template contains all of the possible sections and their default values + +# Note that all fields that take a lint level have these possible values: +# * deny - An error will be produced and the check will fail +# * warn - A warning will be produced, but the check will not fail +# * allow - No warning or error will be produced, though in some cases a note +# will be + +# The values provided in this template are the default values that will be used +# when any section or field is not specified in your own configuration + +# Root options + +# If 1 or more target triples (and optionally, target_features) are specified, +# only the specified targets will be checked when running `cargo deny check`. +# This means, if a particular package is only ever used as a target specific +# dependency, such as, for example, the `nix` crate only being used via the +# `target_family = "unix"` configuration, that only having windows targets in +# this list would mean the nix crate, as well as any of its exclusive +# dependencies not shared by any other crates, would be ignored, as the target +# list here is effectively saying which targets you are building for. +targets = [ + { triple = "aarch64-apple-darwin" }, + { triple = "aarch64-unknown-linux-gnu" }, + { triple = "aarch64-unknown-linux-musl" }, + { triple = "i686-unknown-linux-gnu" }, + { triple = "i686-unknown-linux-musl" }, + { triple = "x86_64-apple-darwin" }, + { triple = "x86_64-unknown-linux-gnu" }, + { triple = "x86_64-unknown-linux-musl" }, + { triple = "x86_64-pc-windows-gnu" }, + { triple = "i686-pc-windows-gnu" } +] +# When creating the dependency graph used as the source of truth when checks are +# executed, this field can be used to prune crates from the graph, removing them +# from the view of cargo-deny. This is an extremely heavy hammer, as if a crate +# is pruned from the graph, all of its dependencies will also be pruned unless +# they are connected to another crate in the graph that hasn't been pruned, +# so it should be used with care. The identifiers are [Package ID Specifications] +# (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html) +#exclude = [] +# If true, metadata will be collected with `--all-features`. Note that this can't +# be toggled off if true, if you want to conditionally enable `--all-features` it +# is recommended to pass `--all-features` on the cmd line instead +all-features = true +# If true, metadata will be collected with `--no-default-features`. The same +# caveat with `all-features` applies +no-default-features = false +# If set, these feature will be enabled when collecting metadata. If `--features` +# is specified on the cmd line they will take precedence over this option. +#features = [] +# When outputting inclusion graphs in diagnostics that include features, this +# option can be used to specify the depth at which feature edges will be added. +# This option is included since the graphs can be quite large and the addition +# of features from the crate(s) to all of the graph roots can be far too verbose. +# This option can be overridden via `--feature-depth` on the cmd line +feature-depth = 1 + +# This section is considered when running `cargo deny check advisories` +# More documentation for the advisories section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html +[advisories] +# The path where the advisory database is cloned/fetched into +db-path = "~/.cargo/advisory-db" +# The url(s) of the advisory databases to use +db-urls = ["https://github.com/rustsec/advisory-db"] +# The lint level for security vulnerabilities +vulnerability = "deny" +# The lint level for unmaintained crates +unmaintained = "warn" +# The lint level for crates that have been yanked from their source registry +yanked = "warn" +# The lint level for crates with security notices. Note that as of +# 2019-12-17 there are no security notice advisories in +# https://github.com/rustsec/advisory-db +notice = "warn" +# A list of advisory IDs to ignore. Note that ignored advisories will still +# output a note when they are encountered. +ignore = [ + #"RUSTSEC-0000-0000", +] +# Threshold for security vulnerabilities, any vulnerability with a CVSS score +# lower than the range specified will be ignored. Note that ignored advisories +# will still output a note when they are encountered. +# * None - CVSS Score 0.0 +# * Low - CVSS Score 0.1 - 3.9 +# * Medium - CVSS Score 4.0 - 6.9 +# * High - CVSS Score 7.0 - 8.9 +# * Critical - CVSS Score 9.0 - 10.0 +severity-threshold = "Medium" + +# If this is true, then cargo deny will use the git executable to fetch advisory database. +# If this is false, then it uses a built-in git library. +# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support. +# See Git Authentication for more information about setting up git authentication. +#git-fetch-with-cli = true + +# This section is considered when running `cargo deny check licenses` +# More documentation for the licenses section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html +[licenses] +# The lint level for crates which do not have a detectable license +unlicensed = "deny" +# List of explicitly allowed licenses +# See https://spdx.org/licenses/ for list of possible licenses +# [possible values: any SPDX 3.11 short identifier (+ optional exception)]. +allow = ["MIT", "Apache-2.0", "Apache-2.0 WITH LLVM-exception", "ISC"] +# List of explicitly disallowed licenses +# See https://spdx.org/licenses/ for list of possible licenses +# [possible values: any SPDX 3.11 short identifier (+ optional exception)]. +deny = [ + #"Nokia", +] +# Lint level for licenses considered copyleft +copyleft = "warn" +# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses +# * both - The license will be approved if it is both OSI-approved *AND* FSF +# * either - The license will be approved if it is either OSI-approved *OR* FSF +# * osi - The license will be approved if it is OSI approved +# * fsf - The license will be approved if it is FSF Free +# * osi-only - The license will be approved if it is OSI-approved *AND NOT* FSF +# * fsf-only - The license will be approved if it is FSF *AND NOT* OSI-approved +# * neither - This predicate is ignored and the default lint level is used +allow-osi-fsf-free = "either" +# Lint level used when no other predicates are matched +# 1. License isn't in the allow or deny lists +# 2. License isn't copyleft +# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither" +default = "deny" +# The confidence threshold for detecting a license from license text. +# The higher the value, the more closely the license text must be to the +# canonical license text of a valid SPDX license file. +# [possible values: any between 0.0 and 1.0]. +confidence-threshold = 0.8 +# Allow 1 or more licenses on a per-crate basis, so that particular licenses +# aren't accepted for every possible crate as with the normal allow list +exceptions = [ + # Each entry is the crate and version constraint, and its specific allow + # list + #{ allow = ["Zlib"], name = "adler32", version = "*" }, +] + +# Some crates don't have (easily) machine readable licensing information, +# adding a clarification entry for it allows you to manually specify the +# licensing information +#[[licenses.clarify]] +# The name of the crate the clarification applies to +#name = "ring" +# The optional version constraint for the crate +#version = "*" +# The SPDX expression for the license requirements of the crate +#expression = "MIT AND ISC AND OpenSSL" +# One or more files in the crate's source used as the "source of truth" for +# the license expression. If the contents match, the clarification will be used +# when running the license check, otherwise the clarification will be ignored +# and the crate will be checked normally, which may produce warnings or errors +# depending on the rest of your configuration +#license-files = [ +# Each entry is a crate relative path, and the (opaque) hash of its contents +#{ path = "LICENSE", hash = 0xbd0eed23 } +#] + +[licenses.private] +# If true, ignores workspace crates that aren't published, or are only +# published to private registries. +# To see how to mark a crate as unpublished (to the official registry), +# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field. +ignore = false +# One or more private registries that you might publish crates to, if a crate +# is only published to private registries, and ignore is true, the crate will +# not have its license(s) checked +registries = [ + #"https://sekretz.com/registry +] + +# This section is considered when running `cargo deny check bans`. +# More documentation about the 'bans' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html +[bans] +# Lint level for when multiple versions of the same crate are detected +multiple-versions = "warn" +# Lint level for when a crate version requirement is `*` +wildcards = "allow" +# The graph highlighting used when creating dotgraphs for crates +# with multiple versions +# * lowest-version - The path to the lowest versioned duplicate is highlighted +# * simplest-path - The path to the version with the fewest edges is highlighted +# * all - Both lowest-version and simplest-path are used +highlight = "all" +# The default lint level for `default` features for crates that are members of +# the workspace that is being checked. This can be overridden by allowing/denying +# `default` on a crate-by-crate basis if desired. +workspace-default-features = "allow" +# The default lint level for `default` features for external crates that are not +# members of the workspace. This can be overridden by allowing/denying `default` +# on a crate-by-crate basis if desired. +external-default-features = "allow" +# List of crates that are allowed. Use with care! +allow = [ + #{ name = "ansi_term", version = "=0.11.0" }, +] +# List of crates to deny +deny = [ + # Each entry the name of a crate and a version range. If version is + # not specified, all versions will be matched. + #{ name = "ansi_term", version = "=0.11.0" }, + # + # Wrapper crates can optionally be specified to allow the crate when it + # is a direct dependency of the otherwise banned crate + #{ name = "ansi_term", version = "=0.11.0", wrappers = [] }, +] + +# List of features to allow/deny +# Each entry the name of a crate and a version range. If version is +# not specified, all versions will be matched. +#[[bans.features]] +#name = "reqwest" +# Features to not allow +#deny = ["json"] +# Features to allow +#allow = [ +# "rustls", +# "__rustls", +# "__tls", +# "hyper-rustls", +# "rustls", +# "rustls-pemfile", +# "rustls-tls-webpki-roots", +# "tokio-rustls", +# "webpki-roots", +#] +# If true, the allowed features must exactly match the enabled feature set. If +# this is set there is no point setting `deny` +#exact = true + +# Certain crates/versions that will be skipped when doing duplicate detection. +skip = [ + #{ name = "ansi_term", version = "=0.11.0" }, +] +# Similarly to `skip` allows you to skip certain crates during duplicate +# detection. Unlike skip, it also includes the entire tree of transitive +# dependencies starting at the specified crate, up to a certain depth, which is +# by default infinite. +skip-tree = [ + #{ name = "ansi_term", version = "=0.11.0", depth = 20 }, +] + +# This section is considered when running `cargo deny check sources`. +# More documentation about the 'sources' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html +[sources] +# Lint level for what to happen when a crate from a crate registry that is not +# in the allow list is encountered +unknown-registry = "warn" +# Lint level for what to happen when a crate from a git repository that is not +# in the allow list is encountered +unknown-git = "warn" +# List of URLs for allowed crate registries. Defaults to the crates.io index +# if not specified. If it is specified but empty, no registries are allowed. +allow-registry = ["https://github.com/rust-lang/crates.io-index"] +# List of URLs for allowed Git repositories +allow-git = [] + +[sources.allow-org] +# 1 or more github.com organizations to allow git sources for +# github = ["AliSajid", "CogDisResLab"] +# 1 or more gitlab.com organizations to allow git sources for +# gitlab = [""] +# 1 or more bitbucket.org organizations to allow git sources for +# bitbucket = [""] diff --git a/meta/licenses.hbs b/meta/licenses.hbs new file mode 100644 index 0000000..32bfeea --- /dev/null +++ b/meta/licenses.hbs @@ -0,0 +1,37 @@ +{{!-- +SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab + +SPDX-License-Identifier: Apache-2.0 +SPDX-License-Identifier: MIT +--}} + +# Third Party Licenses + +This page lists the licenses of the projects used in cargo-about. + +## Overview of licenses + +{{#each overview}} +- [{{{name}}}](#{{{id}}}) ({{count}}) +{{/each}} + +## All license text + +{{#each licenses}} + +### {{{id}}} + +{{{name}}} + +#### Used by + +{{#each used_by}} +- [{{{crate.name}}}]({{#if crate.repository}} {{crate.repository}} {{else}} https://crates.io/crates/{{crate.name}} {{/if}}) {{{crate.version}}} +{{/each}} + +#### License + +```text +{{{text}}} +``` +{{/each}} diff --git a/nextest.toml b/nextest.toml new file mode 100644 index 0000000..3ff86db --- /dev/null +++ b/nextest.toml @@ -0,0 +1,91 @@ +# SPDX-FileCopyrightText: 2024 Cognitive Disorders Research Lab +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: MIT + +# This is the default config used by nextest. It is embedded in the binary at +# build time. It may be used as a template for .config/nextest.toml. + +[store] +# The directory under the workspace root at which nextest-related files are +# written. Profile-specific storage is currently written to dir/. +dir = "target/nextest" + +# This section defines the default nextest profile. Custom profiles are layered +# on top of the default profile. +[profile.default] +# "retries" defines the number of times a test should be retried. If set to a +# non-zero value, tests that succeed on a subsequent attempt will be marked as +# flaky. Can be overridden through the `--retries` option. +# Examples +# * retries = 3 +# * retries = { backoff = "fixed", count = 2, delay = "1s" } +# * retries = { backoff = "exponential", count = 10, delay = "1s", jitter = true, max-delay = "10s" } +retries = 0 + +# The number of threads to run tests with. Supported values are either an integer or +# the string "num-cpus". Can be overridden through the `--test-threads` option. +test-threads = "num-cpus" + +# The number of threads required for each test. This is generally used in overrides to +# mark certain tests as heavier than others. However, it can also be set as a global parameter. +threads-required = 1 + +# Show these test statuses in the output. +# +# The possible values this can take are: +# * none: no output +# * fail: show failed (including exec-failed) tests +# * retry: show flaky and retried tests +# * slow: show slow tests +# * pass: show passed tests +# * skip: show skipped tests (most useful for CI) +# * all: all of the above +# +# Each value includes all the values above it; for example, "slow" includes +# failed and retried tests. +# +# Can be overridden through the `--status-level` flag. +status-level = "all" + +# Similar to status-level, show these test statuses at the end of the run. +final-status-level = "flaky" + +# "failure-output" defines when standard output and standard error for failing tests are produced. +# Accepted values are +# * "immediate": output failures as soon as they happen +# * "final": output failures at the end of the test run +# * "immediate-final": output failures as soon as they happen and at the end of +# the test run; combination of "immediate" and "final" +# * "never": don't output failures at all +# +# For large test suites and CI it is generally useful to use "immediate-final". +# +# Can be overridden through the `--failure-output` option. +failure-output = "immediate-final" + +# "success-output" controls production of standard output and standard error on success. This should +# generally be set to "never". +success-output = "never" + +# Cancel the test run on the first failure. For CI runs, consider setting this +# to false. +fail-fast = false + +# Treat a test that takes longer than the configured 'period' as slow, and print a message. +# See for more information. +# +# Optional: specify the parameter 'terminate-after' with a non-zero integer, +# which will cause slow tests to be terminated after the specified number of +# periods have passed. +# Example: slow-timeout = { period = "60s", terminate-after = 2 } +slow-timeout = { period = "60s", terminate-after = 2 } + +# Treat a test as leaky if after the process is shut down, standard output and standard error +# aren't closed within this duration. +# +# This usually happens in case of a test that creates a child process and lets it inherit those +# handles, but doesn't clean the child process up (especially when it fails). +# +# See for more information. +leak-timeout = "100ms"