Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
FPLeader authored Sep 21, 2023
0 parents commit e340929
Show file tree
Hide file tree
Showing 37 changed files with 17,403 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git
**/target/
**/*.txt
**/*.md
/docker/
!/target/release/polkadot-collator

# dotfiles in the repo root
/.*
29 changes: 29 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
root = true
[*]
indent_style=tab
indent_size=tab
tab_width=4
end_of_line=lf
charset=utf-8
trim_trailing_whitespace=true
max_line_length=100
insert_final_newline=true

[*.yml]
indent_style=space
indent_size=2
tab_width=8
end_of_line=lf

[*.sh]
indent_style=space
indent_size=4
tab_width=8
end_of_line=lf

[*.json]
indent_style=space
indent_size=2
tab_width=8
end_of_line=lf

11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
155 changes: 155 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# This is an example GitHub action that will build and publish the binaries and a Docker image
# You need to add the following secrets to your GitHub Repository or Organization to make this work
# - DOCKERHUB_USERNAME: The username of the DockerHub account. E.g. parity
# - DOCKERHUB_TOKEN: Access token for DockerHub, see https://docs.docker.com/docker-hub/access-tokens/.
# The following is set up as an environment variable below
# - DOCKER_REPO: The unique name of the DockerHub repository. E.g. parity/polkadot

name: Release

permissions:
contents: read

# Controls when the action will run.
on:
push:
# Triggers the workflow on tag push events
tags:
- v[0-9]+.*

env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
CARGO_NET_GIT_FETCH_WITH_CLI: true
CARGO_NET_RETRY: 10
RUSTFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10
CARGO_TERM_COLOR: always
# Set an environment variable (that can be overriden) for the Docker Repo
DOCKER_REPO: tripleight/parachain-template

defaults:
run:
shell: bash


jobs:
create-release:
# The type of runner that the job will run on
runs-on: ubuntu-22.04
timeout-minutes: 60
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: taiki-e/create-gh-release-action@v1
with:
title: $version
branch: main
token: ${{ secrets.GITHUB_TOKEN }}

upload-assets:
name: ${{ matrix.target }}
needs:
- create-release
strategy:
matrix:
# The list of architechture and OS to build for
# You can add or remove targets here if you want
#
# When updating this list, remember to update the target list in tests too
include:
# - target: aarch64-unknown-linux-gnu
- target: x86_64-unknown-linux-gnu
- target: aarch64-apple-darwin
os: macos-11
- target: x86_64-apple-darwin
os: macos-11
# - target: universal-apple-darwin
# os: macos-11

# The type of runner that the job will run on
# Runs on Ubuntu if other os is not specified above
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
timeout-minutes: 90
permissions:
contents: write
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
persist-credentials: false

- name: Install Rust
run: |
rustup update stable --no-self-update
rustup target add wasm32-unknown-unknown
- name: Install linux dependencies
if: (matrix.os == '' || startsWith(matrix.os, 'ubuntu'))
run: |
sudo apt-get -qq update
sudo apt-get install -y protobuf-compiler
- name: Install mac dependencies
if: startsWith(matrix.os, 'macos')
run: brew install protobuf
- uses: taiki-e/setup-cross-toolchain-action@v1
if: (matrix.os == '' || startsWith(matrix.os, 'ubuntu'))
with:
target: ${{ matrix.target }}

# Build and upload the binary to the new release
- uses: taiki-e/upload-rust-binary-action@v1
with:
bin: parachain-template-node
target: ${{ matrix.target }}
tar: all
token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload x86_64 linux binary to workflow
if: (matrix.target == 'x86_64-unknown-linux-gnu')
uses: actions/upload-artifact@v3
with:
name: parachain-template-node
path: ${{ github.workspace }}/target/x86_64-unknown-linux-gnu/release/parachain-template-node

build-image:
# The type of runner that the job will run on
needs:
- upload-assets
runs-on: ubuntu-22.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Login to Docker hub using the credentials stored in the repository secrets
- name: Log in to Docker Hub
uses: docker/login-action@v2.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Check out the repo
uses: actions/checkout@v3

# Download the binary from the previous job
- name: Download x86_64 linux binary
uses: actions/download-artifact@v3
with:
name: parachain-template-node
path: ${{ github.workspace }}

# Build and push 2 images, One with the version tag and the other with latest tag
- name: Build and push Docker images
uses: docker/build-push-action@v4
with:
context: .
file: ./Containerfile
push: true
build-args: |
DOCKER_REPO=${{ env.DOCKER_REPO }}
tags: |
${{ env.DOCKER_REPO }}:${{ github.ref_name }}
${{ env.DOCKER_REPO }}:latest
45 changes: 45 additions & 0 deletions .github/workflows/test-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Test Code

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
pull_request:
branches:
- main
push:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test-code:
runs-on: ubuntu-22.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Code
uses: actions/checkout@v3

- name: Install linux dependencies
run: sudo apt-get install -y clang libssl-dev llvm libudev-dev protobuf-compiler

- name: Install Rust
run: |
rustup update stable --no-self-update
rustup target add wasm32-unknown-unknown
# Rust cache
- uses: Swatinem/rust-cache@v2

# Enable this for clippy linting.
# - name: Check and Lint Code
# run: cargo +nightly clippy -- -D warnings

- name: Check Code
run: cargo check

- name: Test Code
run: cargo test
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Cargo compiled files and executables
**/target/

# These are backup files generated by rustfmt
**/*.rs.bk

# Local chain databases (default location)
**/chains/

# The cache for chain data in container
.local

# The cache for docker container dependency
/.cargo/config

.DS_Store
.idea
.vscode
23 changes: 23 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Basic
hard_tabs = true
max_width = 100
use_small_heuristics = "Max"

# Imports
imports_granularity = "Crate"
reorder_imports = true

# Consistency
newline_style = "Unix"

# Misc
binop_separator = "Back"
chain_width = 80
match_arm_blocks = false
match_arm_leading_pipes = "Preserve"
match_block_trailing_comma = true
reorder_impl_items = false
spaces_around_ranges = false
trailing_comma = "Vertical"
trailing_semicolon = false
use_field_init_shorthand = true
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @sacha-l
Loading

0 comments on commit e340929

Please sign in to comment.