diff --git a/.github/workflows/check_and_lint.yml b/.github/workflows/check_and_lint.yml new file mode 100644 index 0000000..4d0a20d --- /dev/null +++ b/.github/workflows/check_and_lint.yml @@ -0,0 +1,54 @@ +on: + workflow_call: +name: Main workflow +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install rust toolchain + uses: actions-rs/toolchain@v1 + with: + override: true + toolchain: stable + + - uses: Swatinem/rust-cache@v2 + + - name: Run check + run: cargo check --verbose --all --all-features + fmt: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install rust toolchain + uses: actions-rs/toolchain@v1 + with: + override: true + components: rustfmt + toolchain: stable + + - uses: Swatinem/rust-cache@v2 + + - name: Run fmt + run: cargo fmt --all --check --verbose + clippy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install rust toolchain + uses: actions-rs/toolchain@v1 + with: + override: true + components: clippy + toolchain: stable + + - uses: Swatinem/rust-cache@v2 + + - name: Run clippy + run: cargo clippy \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..0551c71 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,29 @@ +on: + workflow_call: +name: Docker build and publish +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64 + push: true + tags: liamadamson/room-monitor:latest \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8da3c85..3e950ed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,71 +1,11 @@ on: push: + branches-ignore: + - main pull_request: name: Main workflow jobs: - tests: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install rust toolchain - uses: actions-rs/toolchain@v1 - with: - override: true - toolchain: stable - - - uses: Swatinem/rust-cache@v2 - - - name: Run tests - run: cargo test --verbose --all --all-features - check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install rust toolchain - uses: actions-rs/toolchain@v1 - with: - override: true - toolchain: stable - - - uses: Swatinem/rust-cache@v2 - - - name: Run check - run: cargo check --verbose --all --all-features - fmt: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install rust toolchain - uses: actions-rs/toolchain@v1 - with: - override: true - components: rustfmt - toolchain: stable - - - uses: Swatinem/rust-cache@v2 - - - name: Run fmt - run: cargo fmt --all --check --verbose - clippy: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install rust toolchain - uses: actions-rs/toolchain@v1 - with: - override: true - components: clippy - toolchain: stable - - - uses: Swatinem/rust-cache@v2 - - - name: Run clippy - run: cargo clippy \ No newline at end of file + check-and-lint: + uses: ./.github/workflows/check_and_lint.yml + test: + uses: ./.github/workflows/test.yml \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..39458f7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,13 @@ +on: + push: + branches: + - main +name: Release +jobs: + check-and-lint: + uses: ./.github/workflows/check_and_lint.yml + test: + uses: ./.github/workflows/test.yml + docker-release: + needs: [check-and-lint, test] + uses: ./.github/workflows/docker.yml \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b0bc7f2 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,20 @@ +on: + workflow_call: +name: Tests +jobs: + tests: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install rust toolchain + uses: actions-rs/toolchain@v1 + with: + override: true + toolchain: stable + + - uses: Swatinem/rust-cache@v2 + + - name: Run tests + run: cargo test --verbose --all --all-features \ No newline at end of file