diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index d970aa1..a4cf463 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -3,40 +3,46 @@ name: Backend CI on: push: paths: - - '.github/workflows/**' + - '.github/workflows/backend.yml' - 'backend/**' - '!frontend/**' +env: + CARGO_TERM_COLOR: always + +defaults: + run: + working-directory: ./backend + jobs: build: + name: Check Code runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 + - name: Checkout sources + uses: actions/checkout@v2.3.4 - - name: Build telemetry executables (in debug mode) - working-directory: ./backend - run: cargo build --bins --verbose + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1.0.7 + with: + profile: minimal + toolchain: stable + override: true - - name: Run tests - working-directory: ./backend - run: cargo test --verbose --jobs 1 + - name: Rust Cache + uses: Swatinem/rust-cache@v1.3.0 + with: + working-directory: backend - - name: Check internal documentation links - working-directory: ./backend - run: RUSTDOCFLAGS="--deny broken_intra_doc_links" cargo doc --verbose --workspace --no-deps --document-private-items + - name: Build + run: cargo check --all-targets - - name: Ensure 'cargo fmt' has been used - working-directory: ./backend - run: cargo fmt --all -- --check - - - name: Build, release and call telemetry executable - working-directory: ./backend - run: cargo run --bin telemetry_core --release -- --help - - - name: Build, release and call shard executable - working-directory: ./backend - run: cargo run --bin telemetry_shard --release -- --help + docker: + name: Push tagged images to docker + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2.3.4 - name: Login to Dockerhub uses: docker/login-action@v1 @@ -52,12 +58,92 @@ jobs: tags: parity/substrate-telemetry-backend:latest # add_git_labels: true - e2e: + fmt: + name: Run rustfmt runs-on: ubuntu-latest - continue-on-error: true steps: - - uses: actions/checkout@v2 + - name: Checkout sources + uses: actions/checkout@v2.3.4 - - name: Run (potentially brittle) E2E tests - working-directory: ./backend - run: cargo test --verbose --jobs 1 --features e2e 'e2e' \ No newline at end of file + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1.0.7 + with: + profile: minimal + toolchain: stable + override: true + components: clippy, rustfmt + + - name: Rust Cache + uses: Swatinem/rust-cache@v1.3.0 + with: + working-directory: backend + + - name: Cargo fmt + run: cargo fmt --all -- --check + + docs: + name: Check Documentation + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2.3.4 + + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1.0.7 + with: + profile: minimal + toolchain: stable + override: true + + - name: Rust Cache + uses: Swatinem/rust-cache@v1.3.0 + with: + working-directory: backend + + - name: Check internal documentation links + run: RUSTDOCFLAGS="--deny broken_intra_doc_links" cargo doc --verbose --workspace --no-deps --document-private-items + + tests: + name: Run tests + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2.3.4 + + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1.0.7 + with: + profile: minimal + toolchain: stable + override: true + + - name: Rust Cache + uses: Swatinem/rust-cache@v1.3.0 + with: + working-directory: backend + + - name: Cargo test + run: cargo test --verbose --jobs 1 + + e2e: + name: Run potentially brittle E2E tests + continue-on-error: true + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2.3.4 + + - name: Install Rust stable toolchain + uses: actions-rs/toolchain@v1.0.7 + with: + profile: minimal + toolchain: stable + override: true + + - name: Rust Cache + uses: Swatinem/rust-cache@v1.3.0 + with: + working-directory: backend + + - name: Cargo test + run: cargo test --verbose --jobs 1 --features e2e 'e2e' diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index b6b55ef..73553ae 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -6,13 +6,16 @@ name: Frontend CI on: push: paths: - - '.github/workflows/**' + - '.github/workflows/frontend.yml' - 'frontend/**' - '!backend/**' +defaults: + run: + working-directory: ./frontend + jobs: build: - runs-on: ubuntu-latest strategy: @@ -21,27 +24,30 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} + - name: install - working-directory: ./frontend run: yarn install + - name: check run: yarn pretty:check - working-directory: ./frontend + - name: Test run: yarn test - working-directory: ./frontend + - name: Build - working-directory: ./frontend run: yarn build + - name: Login to Dockerhub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and Push template image uses: docker/build-push-action@v2 # https://github.com/docker/build-push-action if: matrix.node-version == '12.x'