diff options
| -rw-r--r-- | .github/actions/setup-nix/action.yaml | 17 | ||||
| -rw-r--r-- | .github/workflows/audit.yaml | 6 | ||||
| -rw-r--r-- | .github/workflows/ci.yaml | 85 | ||||
| -rw-r--r-- | .github/workflows/format.yaml | 41 | ||||
| -rw-r--r-- | .github/workflows/lint.yaml | 25 | ||||
| -rw-r--r-- | .github/workflows/update-flake.yaml | 7 | ||||
| -rw-r--r-- | .github/workflows/upload.yaml | 42 | ||||
| -rw-r--r-- | garnix.yaml | 5 | ||||
| -rw-r--r-- | parts/default.nix | 7 | ||||
| -rw-r--r-- | parts/dev.nix | 9 | ||||
| -rw-r--r-- | parts/packages.nix | 5 |
11 files changed, 54 insertions, 195 deletions
diff --git a/.github/actions/setup-nix/action.yaml b/.github/actions/setup-nix/action.yaml deleted file mode 100644 index 8afecd1..0000000 --- a/.github/actions/setup-nix/action.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: "setup nix & cachix" -description: "setup nix and cachix" -inputs: - cachix-token: - description: "cachix auth token" - default: "" - required: false - -runs: - using: "composite" - steps: - - uses: cachix/install-nix-action@v21 - - - uses: cachix/cachix-action@v12 - with: - name: getchoo - authToken: ${{ inputs.cachix-token }} diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml index 677ea14..ade1ce9 100644 --- a/.github/workflows/audit.yaml +++ b/.github/workflows/audit.yaml @@ -5,12 +5,6 @@ name: audit crates on: schedule: - cron: "0 0 * * 6" - push: - paths: - - "Cargo.lock" - pull_request: - paths: - - "Cargo.lock" workflow_dispatch: jobs: diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index bebf885..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,85 +0,0 @@ -name: ci - -on: - push: - pull_request: - workflow_dispatch: - -permissions: - contents: write - packages: write - -jobs: - lint: - name: lint project - uses: ./.github/workflows/lint.yaml - - format: - name: format project - uses: ./.github/workflows/format.yaml - - build: - runs-on: ubuntu-latest - needs: lint - - strategy: - matrix: - output: [teawiebot, container] - - steps: - - uses: actions/checkout@v3 - - - name: setup nix & cachix - uses: ./.github/actions/setup-nix - with: - cachix-token: ${{ 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 }} - 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: 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/format.yaml b/.github/workflows/format.yaml deleted file mode 100644 index e189f46..0000000 --- a/.github/workflows/format.yaml +++ /dev/null @@ -1,41 +0,0 @@ -name: format project - -on: - workflow_call: - workflow_dispatch: - -permissions: - contents: write - -jobs: - cargo-fmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: setup nix & cachix - uses: ./.github/actions/setup-nix - with: - cachix-token: ${{ secrets.CACHIX_AUTH_TOKEN }} - - - name: run cargo fmt - run: | - nix build -L .#checks.x86_64-linux.fmt - - nix-fmt: - runs-on: ubuntu-latest - if: github.event_name != 'pull_request' - steps: - - uses: actions/checkout@v3 - - - name: setup nix & cachix - uses: ./.github/actions/setup-nix - with: - cachix-token: ${{ secrets.CACHIX_AUTH_TOKEN }} - - - 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 deleted file mode 100644 index aab9e34..0000000 --- a/.github/workflows/lint.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: lint project - -on: - workflow_call: - workflow_dispatch: - -jobs: - lint: - runs-on: ubuntu-latest - - strategy: - matrix: - check: [teawiebot, clippy] - - steps: - - uses: actions/checkout@v3 - - - name: setup nix & cachix - uses: ./.github/actions/setup-nix - with: - cachix-token: ${{ secrets.CACHIX_AUTH_TOKEN }} - - - name: lint - run: | - nix build -L .#checks.x86_64-linux.${{ matrix.check }} diff --git a/.github/workflows/update-flake.yaml b/.github/workflows/update-flake.yaml index 04178d7..9ac2d4e 100644 --- a/.github/workflows/update-flake.yaml +++ b/.github/workflows/update-flake.yaml @@ -8,7 +8,6 @@ on: workflow_dispatch: permissions: - contents: write pull-requests: write jobs: @@ -17,11 +16,7 @@ jobs: steps: - uses: actions/checkout@v3 - - - name: setup nix & cachix - uses: ./.github/actions/setup-nix - with: - cachix-token: ${{ secrets.CACHIX_AUTH_TOKEN }} + - uses: cachix/install-nix-action@v22 - uses: DeterminateSystems/update-flake-lock@v19 with: diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml new file mode 100644 index 0000000..1122491 --- /dev/null +++ b/.github/workflows/upload.yaml @@ -0,0 +1,42 @@ +name: upload to registry +# this is for uploading images to a container registry when +# changes are made to `main` + +on: + check_suite: + types: [completed] + +permissions: + packages: write + +jobs: + upload: + runs-on: ubuntu-latest + + env: + REGISTRY: ghcr.io + USERNAME: getchoo + + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 + + - name: fetch docker image + run: | + nix build --accept-flake-config -L .#container + readlink result | xargs -I {} cp {} teawiebot.tar.gz + + - name: login to ${{ env.REGISTRY }} + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.USERNAME }} + password: ${{ github.token }} + + - name: upload to ${{ env.REGISTRY }} + env: + PUSH_PREFIX: ${{ env.REGISTRY }}/${{ env.USERNAME }} + run: | + docker load < teawiebot.tar.gz + docker tag teawiebot:latest ${{ env.REGISTRY_PREFIX }}/teawiebot:latest + docker push ${{ env.PUSH_PREFIX }}/teawiebot:latest diff --git a/garnix.yaml b/garnix.yaml new file mode 100644 index 0000000..296a431 --- /dev/null +++ b/garnix.yaml @@ -0,0 +1,5 @@ +builds: + exclude: [] + include: + - "packages.x86_64-linux.*" + - "devShells.x86_64-linux.default" diff --git a/parts/default.nix b/parts/default.nix index ecace0f..0f093f8 100644 --- a/parts/default.nix +++ b/parts/default.nix @@ -12,11 +12,4 @@ _: { "aarch64-linux" "aarch64-darwin" ]; - - perSystem = _: { - _module.args.src = builtins.path { - name = "teawiebot-src"; - path = ../.; - }; - }; } diff --git a/parts/dev.nix b/parts/dev.nix index 65fcfd0..246789a 100644 --- a/parts/dev.nix +++ b/parts/dev.nix @@ -7,15 +7,14 @@ craneLib, pkgs, system, - src, toolchain, ... - } @ args: { + }: { checks = let - inherit (craneLib) cargoAudit cargoClippy cleanCargoSource cargoFmt path; + inherit (craneLib) cargoAudit cargoClippy cleanCargoSource cargoFmt; commonArgs = { - src = cleanCargoSource (path args.src); + src = cleanCargoSource self; }; in { inherit (self.packages.${system}) teawiebot; @@ -31,7 +30,7 @@ fmt = cargoFmt commonArgs; pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run { - inherit src; + src = self; hooks = { actionlint.enable = true; alejandra.enable = true; diff --git a/parts/packages.nix b/parts/packages.nix index 1b8acd8..f44ac50 100644 --- a/parts/packages.nix +++ b/parts/packages.nix @@ -2,7 +2,6 @@ perSystem = { craneLib, pkgs, - src, system, ... }: let @@ -10,10 +9,10 @@ inherit (craneLib) buildPackage; in { packages = { - cargoArtifacts = craneLib.buildDepsOnly {inherit src;}; + cargoArtifacts = craneLib.buildDepsOnly {src = self;}; teawiebot = buildPackage { - inherit src; + src = self; inherit (self.packages.${system}) cargoArtifacts; meta = { |
