diff options
| author | seth <[email protected]> | 2023-05-30 01:43:34 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2023-05-30 02:11:19 -0400 |
| commit | bad6165346f8b504662b3fa993791e9564a542cf (patch) | |
| tree | 30a501e4e17e2d87a8f03c91196f4ecdc96e5fb8 | |
| parent | 773f2decdf479c5a08c4fc0f7361f8de619aae40 (diff) | |
ci: separate workflows more + add more tests
| -rw-r--r-- | .github/workflows/check.yml | 33 | ||||
| -rw-r--r-- | .github/workflows/ci.yaml | 91 | ||||
| -rw-r--r-- | .github/workflows/ci.yml | 62 | ||||
| -rw-r--r-- | .github/workflows/format.yaml | 47 | ||||
| -rw-r--r-- | .github/workflows/lint.yaml | 42 |
5 files changed, 180 insertions, 95 deletions
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 8460c2c..0000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: check project - -on: - push: - paths: - - "**.lock" - - "**.nix" - - "**.rs" - - "**.toml" - - pull_request: - paths: - - "**.lock" - - "**.nix" - - "**.rs" - - "**.toml" - - workflow_dispatch: - -jobs: - check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - uses: cachix/install-nix-action@v21 - - - uses: cachix/cachix-action@v12 - with: - name: getchoo - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - - - run: nix flake check --accept-flake-config -L diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..942f67c --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,91 @@ +name: ci + +on: + push: + pull_request: + workflow_dispatch: + +permissions: + checks: write + contents: write + packages: write + +jobs: + lint: + name: lint project + uses: ./.github/workflows/lint.yaml + + format: + name: format project + if: github.event_name != 'pull_request' + needs: lint + uses: ./.github/workflows/format.yaml + + build: + runs-on: ubuntu-latest + needs: format + if: always() && (needs.format.result == 'success' || needs.format.result == 'skipped') + + strategy: + matrix: + output: [teawiebot, container] + + steps: + - uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v21 + + - uses: cachix/cachix-action@v12 + with: + name: getchoo + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: build + run: | + nix build --accept-flake-config -L .#${{ matrix.output }} + + - name: copy docker image + if: ${{ matrix.output == 'container' }} + run: | + readlink result | xargs -I{} cp {} teawiebot.tar.gz + + - name: upload binary + if: ${{ matrix.output == 'teawiebot' }} + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.output }} + path: result/bin/${{ matrix.output }} + + - name: upload docker image + if: ${{ matrix.output == 'container' }} + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.output }}-container + path: teawiebot.tar.gz + + upload-to-docker: + runs-on: ubuntu-latest + needs: build + if: github.ref == 'refs/heads/main' + + env: + REGISTRY: ghcr.io + + steps: + - name: download docker image + uses: actions/download-artifact@v3 + with: + name: teawiebot-container + + - name: login to ghcr + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: "getchoo" + password: ${{ secrets.GITHUB_TOKEN }} + + - name: upload to ghcr + run: | + docker load < teawiebot.tar.gz + docker tag teawiebot:latest ghcr.io/getchoo/teawiebot:latest + docker push ghcr.io/getchoo/teawiebot:latest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index d0b11dd..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: ci - -on: - push: - paths: - - "**.lock" - - "**.nix" - - "**.rs" - - "**.toml" - - pull_request: - paths: - - "**.lock" - - "**.nix" - - "**.rs" - - "**.toml" - - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - permissions: - contents: read - packages: write - - strategy: - matrix: - output: [teawiebot, container] - - env: - REGISTRY: ghcr.io - - steps: - - uses: actions/checkout@v3 - - - uses: cachix/install-nix-action@v21 - - - uses: cachix/cachix-action@v12 - with: - name: getchoo - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - - - name: login to ghcr - if: ${{ matrix.output == 'container' && github.ref == 'refs/heads/main' }} - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: "getchoo" - password: ${{ secrets.GITHUB_TOKEN }} - - - name: build - run: | - nix build --accept-flake-config -L .#${{ matrix.output }} - - - name: upload to ghcr - if: ${{ matrix.output == 'container' && github.ref == 'refs/heads/main' }} - run: | - docker load < result - docker tag teawiebot:latest ghcr.io/getchoo/teawiebot:latest - docker push ghcr.io/getchoo/teawiebot:latest diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml new file mode 100644 index 0000000..b0eaddd --- /dev/null +++ b/.github/workflows/format.yaml @@ -0,0 +1,47 @@ +name: format project + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: write + +jobs: + cargo-fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: clippy + + - name: run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all + + - uses: EndBug/add-and-commit@v9 + with: + default_author: github_actions + message: "chore: fmt rust files" + + nix-fmt: + runs-on: ubuntu-latest + needs: cargo-fmt + steps: + - uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v21 + + - run: nix fmt + + - uses: EndBug/add-and-commit@v9 + with: + default_author: github_actions + message: "chore: fmt nix files" diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..550e406 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,42 @@ +name: lint project + +on: + workflow_call: + workflow_dispatch: + +permissions: + checks: write + +jobs: + cargo-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: run cargo check + uses: actions-rs/cargo@v1 + with: + command: check + + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: clippy + + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features |
