Skip to content

Commit

Permalink
* Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
DidacSF committed Feb 15, 2024
0 parents commit 0890b09
Show file tree
Hide file tree
Showing 78 changed files with 51,275 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[alias]
build-bajun = "build --release --no-default-features --bin bajun-node"
build-bajun-benchmarks = [ "build-bajun", "--features", "runtime-benchmarks" ]

[target.'cfg(feature = "cargo-clippy")']
rustflags = [
"-Aclippy::derive_partial_eq_without_eq",
"-Aclippy::too_many_arguments",
"-Aclippy::type_complexity",
"-Aclippy::uninlined-format-args",
"-Aclippy::unnecessary_cast",
"-Aclippy::large_enum_variant",
]
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

[*]
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.rs]
indent_style = tab
indent_size = tab
tab_width = 4
max_line_length = 100

[*.toml]
indent_size = 4
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/ask-a-question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: Ask a Question
about: Ask a question about this template.
title: ""
labels: question
assignees: ""
---

**Question**

_Please include information such as the following: is your question to clarify an existing resource
or are you asking about something new? what are you trying to accomplish? where have you looked for
answers?_
46 changes: 46 additions & 0 deletions .github/ISSUE_TEMPLATE/report-a-bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: Report a Bug
about: Report a problem with this template.
title: ""
labels: bug
assignees: ""
---

**Description**

_Tell us what happened. In particular, be specific about any changes you made to this template.
Ideally, provide a link to your project's GitHub repository. Please note that we are not able to
support all conceivable changes to this template project, but the more information you are able to
provide the more equipped we will be to help._

**Steps to Reproduce**

_Replace the example steps below with actual steps to reproduce the bug you're reporting._

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected vs. Actual Behavior**

_What did you expect to happen after you followed the steps you described in the last section? What
actually happened?_

**Environment**

_Describe the environment in which you encountered this bug. Use the list below as a starting point
and add additional information if you think it's relevant._

- Operating system:
- Template version/tag:
- Rust version (run `rustup show`):

**Logs, Errors or Screenshots**

_Please provide the text of any logs or errors that you experienced; if
applicable, provide screenshots to help illustrate the problem._

**Additional Information**

_Please add any other details that you think may help us solve your problem._
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/suggest-a-feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Suggest a Feature
about: Suggest a new feature or an improvement to an existing feature for this template.
title: ""
labels: enhancement
assignees: ""
---

**Motivation**

_Describe the need or frustration that motivated you to make this suggestion. Please note that the
goal of this project is to provide a general-purpose template project, so please take care when
suggesting features that may be specific to a particular use case._

**Suggested Solution**

_Describe your suggested solution to the need or frustration that you are experiencing._

**Alternatives**

_Describe any alternative solutions or features you considered and why you believe your suggested
solution is preferable._

**Additional Information**

_Provide any additional information that you believe may help us evaluate your suggestion._
22 changes: 22 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Description

Please describe your pull request and link relevant issues.

## Type of changes

- [ ] `build`: Changes that affect the build system or external dependencies (eg, Cargo, Docker)
- [ ] `ci`: Changes to CI configuration
- [ ] `docs`: Changes to documentation only
- [ ] `feat`: Changes to add a new feature
- [ ] `fix`: Changes to fix a bug
- [ ] `refactor`: Changes that do not alter functionality
- [ ] `style`: Changes to format the code
- [ ] `test`: Changes to add missing tests or correct existing tests

## Checklist

- [ ] Tests for the changes have been added
- [ ] Necessary documentation is added (if appropriate)
- [ ] Formatted with `cargo fmt --all`
- [ ] Linted with `cargo clippy --all-features --all-targets`
- [ ] Tested with `cargo test --workspace --all-features --all-targets`
47 changes: 47 additions & 0 deletions .github/scripts/free_disk_space.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

get_available_space() {
echo $(df -a $1 | awk 'NR > 1 {avail+=$4} END {print avail}')
}

BEFORE_SPACE=$(get_available_space)

# REF: https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh
echo "Removing large packages"
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y 'php.*'
sudo apt-get remove -y '^mongodb-.*'
sudo apt-get remove -y '^mysql-.*'
sudo apt-get remove -y \
azure-cli \
google-cloud-sdk \
hhvm \
google-chrome-stable \
firefox \
powershell \
mono-devel \
libgl1-mesa-dri
sudo apt-get autoremove -y
sudo apt-get clean

# REF: https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh
echo "Removing large directories"
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/graalvm
sudo rm -rf /usr/local/.ghcup /opt/ghc
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/local/lib/node_modules

# REF: https://github.com/actions/runner-images/issues/2875#issuecomment-1163392159
echo "Removing tool cache"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"

echo "Removing swap storage"
sudo swapoff -a
sudo rm -f /mnt/swapfile

echo "Finding space freed up"
AFTER_SPACE=$(get_available_space)
printf "%'.f\n" $((AFTER_SPACE - BEFORE_SPACE))
82 changes: 82 additions & 0 deletions .github/workflows/check-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: "Check Pull Request"

on:
pull_request:
branches:
- develop
paths:
- "**/*.rs"
- "**/Cargo.toml"
- "**/Cargo.lock"
- "rust-toolchain.toml"
- "rustfmt.toml"
- ".github/workflows/*.yml"
push:
branches:
- develop

# Ensures only one build is run per branch, unless pushing to develop
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/develop' && github.run_number || github.ref }}
cancel-in-progress: true

env:
CARGO_ARGS: ${{ github.ref == 'refs/heads/develop' && '--release' || '' }}
CARGO_TERM_COLOR: always
SKIP_WASM_BUILD: 1

jobs:
fmt:
if: ${{ !startsWith(github.head_ref, 'release/') }}
name: Rustfmt
runs-on: ubuntu-latest
continue-on-error: false
steps:
- uses: actions/checkout@v4
- run: cargo fmt --all -- --check

lint:
if: ${{ !startsWith(github.head_ref, 'release/') }}
name: Clippy
runs-on: ubuntu-latest
continue-on-error: false
steps:
- uses: actions/checkout@v4
- run: ./.github/scripts/free_disk_space.sh
- run: sudo apt-get install -y protobuf-compiler
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-lint-
- run: cargo clippy --workspace --all-features --all-targets ${{ env.CARGO_ARGS }} -- -D warnings

test:
if: ${{ !startsWith(github.head_ref, 'release/') }}
name: Test
runs-on: ubuntu-latest
continue-on-error: false
strategy:
matrix:
runtime:
- bajun-runtime
steps:
- uses: actions/checkout@v4
- run: ./.github/scripts/free_disk_space.sh
- run: sudo apt-get install -y protobuf-compiler
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-test-${{ matrix.runtime }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-test-${{ matrix.runtime }}-
- run: cargo test --all-features --all-targets ${{ env.CARGO_ARGS }} -p ${{ matrix.runtime }}
31 changes: 31 additions & 0 deletions .github/workflows/cleanup-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
name: "Cleanup caches by a branch"
on:
pull_request:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 0890b09

Please sign in to comment.