diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..395cb8b0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +/target/ +/.idea/ +/.github/ +/.devcontainer/ +/.vscode/ +/.git/ +Dockerfile diff --git a/.github/workflows/build-no-std.yml b/.github/workflows/build-no-std.yml new file mode 100644 index 00000000..c07c53b3 --- /dev/null +++ b/.github/workflows/build-no-std.yml @@ -0,0 +1,35 @@ +name: Build no-std +on: + push: + branches: + - main + pull_request: + types: [opened, repoened, synchronize] + +jobs: + build-no-std: + strategy: + fail-fast: false + matrix: + target: + - { name: Linux, os: ubuntu-latest, triple: x86_64-unknown-linux-gnu } + version: + - stable + - nightly + name: ${{ matrix.version }} - Build no-std + runs-on: ${{ matrix.target.os }} + steps: + - uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/build-push-action@v3 + with: + target: build-no-std + build-args: | + TOOLCHAIN_VERSION=${{ matrix.version }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index dc153e49..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,114 +0,0 @@ -name: CI -on: - push: - branches: - - main - pull_request: - types: [opened, repoened, synchronize] - -jobs: - test: - name: Test Rust ${{matrix.toolchain}} on ${{matrix.os}} - runs-on: ${{matrix.os}}-latest - strategy: - fail-fast: false - matrix: - toolchain: [stable, nightly] - os: [ubuntu] - steps: - - uses: actions/checkout@main - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{matrix.toolchain}} - override: true - - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{matrix.toolchain}} - override: true - - name: Test - uses: actions-rs/cargo@v1 - with: - command: test - - clippy: - name: Clippy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@main - - name: Install minimal nightly with clippy - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - components: clippy - override: true - - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - components: clippy - override: true - - - name: Clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all -- -D clippy::all -D warnings - - rustfmt: - name: rustfmt - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@main - - name: Install minimal nightly with rustfmt - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - components: rustfmt - override: true - - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - components: rustfmt - override: true - - - name: rustfmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - no-std: - name: no-std - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - toolchain: [stable, nightly] - target: - - wasm32-unknown-unknown - steps: - - uses: actions/checkout@main - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{matrix.toolchain}} - override: true - - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{matrix.toolchain}} - override: true - - - run: rustup target add wasm32-unknown-unknown - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --verbose --no-default-features --target ${{ matrix.target }} diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..1f80c039 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,34 @@ +name: Format +on: + push: + branches: + - main + pull_request: + types: [opened, repoened, synchronize] + +jobs: + format: + strategy: + fail-fast: false + matrix: + target: + - { name: Linux, os: ubuntu-latest, triple: x86_64-unknown-linux-gnu } + version: + - nightly + name: ${{ matrix.version }} - Format + runs-on: ${{ matrix.target.os }} + steps: + - uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/build-push-action@v3 + with: + target: fmt + build-args: | + TOOLCHAIN_VERSION=${{ matrix.version }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..4fe5b296 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,34 @@ +name: Lint +on: + push: + branches: + - main + pull_request: + types: [opened, repoened, synchronize] + +jobs: + lint: + strategy: + fail-fast: false + matrix: + target: + - { name: Linux, os: ubuntu-latest, triple: x86_64-unknown-linux-gnu } + version: + - nightly + name: ${{ matrix.version }} - Lint + runs-on: ${{ matrix.target.os }} + steps: + - uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/build-push-action@v3 + with: + target: lint + build-args: | + TOOLCHAIN_VERSION=${{ matrix.version }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..90a904dd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,35 @@ +name: Test +on: + push: + branches: + - main + pull_request: + types: [opened, repoened, synchronize] + +jobs: + test: + strategy: + fail-fast: false + matrix: + target: + - { name: Linux, os: ubuntu-latest, triple: x86_64-unknown-linux-gnu } + version: + - stable + - nightly + name: ${{ matrix.version }} - Test + runs-on: ${{ matrix.target.os }} + steps: + - uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/build-push-action@v3 + with: + target: test + build-args: | + TOOLCHAIN_VERSION=${{ matrix.version }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..6e86acf3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +FROM rust:latest AS base + +ARG TOOLCHAIN_VERSION +ARG GITHUB_TOKEN + +ENV CARGO_TERM_COLOR=always +ENV RUSTFLAGS=-Dwarnings +ENV RUST_BACKTRACE=1 + +RUN git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/" + +RUN apt update && \ + apt install -y clang + +RUN rustup toolchain install ${TOOLCHAIN_VERSION} && \ + rustup default ${TOOLCHAIN_VERSION} && \ + rustup target add wasm32-unknown-unknown + +WORKDIR /usr/src/app + +FROM base AS build-no-std +COPY . . +RUN cargo build --verbose --no-default-features + +FROM base AS test +COPY . . +RUN cargo test + +FROM base AS fmt +RUN rustup component add rustfmt +COPY . . +RUN cargo fmt --all -- --check + +FROM base AS lint +RUN rustup component add clippy +COPY . . +RUN cargo clippy --all -- -D clippy::all -D warnings