Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #35 from toposware/ci-use-docker
Browse files Browse the repository at this point in the history
ci: run workflows in docker
  • Loading branch information
Nashtare authored Aug 26, 2022
2 parents aa3c851 + 7fa71d1 commit cc76c91
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 114 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/target/
/.idea/
/.github/
/.devcontainer/
/.vscode/
/.git/
Dockerfile
35 changes: 35 additions & 0 deletions .github/workflows/build-no-std.yml
Original file line number Diff line number Diff line change
@@ -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 }}
114 changes: 0 additions & 114 deletions .github/workflows/ci.yml

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -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 }}
34 changes: 34 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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 }}
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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 }}
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cc76c91

Please sign in to comment.