diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml deleted file mode 100644 index ea38adb..0000000 --- a/.buildkite/pipeline.yml +++ /dev/null @@ -1,56 +0,0 @@ -# SPDX-FileCopyrightText: 2019-2021 Serokell -# -# SPDX-License-Identifier: MPL-2.0 - -steps: - - command: nix flake check -L --allow-import-from-derivation - label: Check flake - - - label: shellcheck - command: nix shell .#shellcheck -c find . -name '*.sh' -exec shellcheck {} + - - - label: stylish - command: nix shell .#gnumake .#stylish-haskell -c ./scripts/validate-stylish.sh - - - command: nix build -L .#"xrefcheck:lib:xrefcheck" .#"xrefcheck:test:ftp-tests" .#"xrefcheck:test:xrefcheck-tests" - label: Library and tests - - - command: nix shell .#bats .#diffutils .#xrefcheck-static -c bash -c "cd tests/golden/ && bats ./**" - label: Golden tests (bats) - - - command: nix build -L .#xrefcheck-static - label: Executable - artifact_paths: - - "result/bin/xrefcheck" - - - command: nix build -L .#xrefcheck-windows - label: Windows executable - artifact_paths: - - "result/bin/*" - - - command: nix run . -L - label: Xrefcheck itself - retry: - automatic: - limit: 2 - - - label: lint - command: nix shell .#haskellPackages.hlint -c hlint . - - - command: - - nix shell .#curl .#gitAndTools.hub -c bash -c "curl https://raw.githubusercontent.com/serokell/scratch/release-binary/scripts/release-binary.sh | bash" - label: Create a pre-release - branches: master - - - command: - - nix build -L .#docker-image - - nix shell .#skopeo -c ./scripts/upload-docker-image.sh "docker-archive:$(readlink result)" "docker://docker.io/serokell/xrefcheck:latest" - label: Push to dockerhub - branches: master - - - command: - - nix build .#docker-image - - nix shell .#skopeo -c ./scripts/upload-docker-image.sh "docker-archive:$(readlink result)" "docker://docker.io/serokell/xrefcheck:${BUILDKITE_BRANCH}" - label: Push release to dockerhub - if: | - build.tag =~ /^v[0-9]+.*/ diff --git a/.github/workflows/autorelease.yml b/.github/workflows/autorelease.yml new file mode 100644 index 0000000..e143d2a --- /dev/null +++ b/.github/workflows/autorelease.yml @@ -0,0 +1,27 @@ +# SPDX-FileCopyrightText: 2023 Serokell +# +# SPDX-License-Identifier: MPL-2.0 + +name: master-update + +on: + push: + branches: + - master + +jobs: + release: + runs-on: [self-hosted, nix] + steps: + - uses: actions/checkout@v3 + + - name: Create a pre-release + run: | + export GITHUB_TOKEN=${{ env.GITHUB_TOKEN }} + nix shell .#curl .#gitAndTools.hub -c bash -c "curl https://raw.githubusercontent.com/serokell/scratch/release-binary/scripts/release-binary.sh | bash" + + - name: Push latest image to dockerhub + run: | + export DOCKERHUB_PASSWORD=${{ env.DOCKERHUB_PASSWORD }} + nix build -L .#docker-image + nix shell .#skopeo -c ./scripts/upload-docker-image.sh "docker-archive:$(readlink result)" "docker://docker.io/serokell/xrefcheck:latest" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b12e87..d7f9894 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,10 +10,36 @@ name: CI -on: [push] +on: [pull_request] jobs: - xrefcheck-build-and-test: + validate: + runs-on: [self-hosted, nix] + steps: + - uses: actions/checkout@v3 + + - name: reuse + run: nix build -L .#checks.x86_64-linux.reuse-lint + # Run step even if the previous one has failed + if: success() || failure() + + - name: hlint + run: nix build -L .#checks.x86_64-linux.hlint + if: success() || failure() + + - name: shellcheck + run: nix build -L .#checks.x86_64-linux.shellcheck + if: success() || failure() + + - name: stylish-haskell + run: nix build -L .#checks.x86_64-linux.stylish-haskell + if: success() || failure() + + - name: check-trailing-whitespace + run: nix build -L .#checks.x86_64-linux.trailing-whitespace + if: success() || failure() + + xrefcheck-build-and-test-windows: runs-on: windows-latest strategy: matrix: @@ -27,7 +53,7 @@ jobs: with: submodules: 'true' - - uses: haskell/actions/setup@v2.0.1 + - uses: haskell/actions/setup@v2.4.3 id: setup-haskell-stack name: Setup Haskell Stack with: @@ -79,3 +105,47 @@ jobs: export PATH=$PATH:/c/Users/runneradmin/AppData/Roaming/local/bin; bats ./tests/golden/** shell: bash + + xrefcheck-build-and-test-nix: + runs-on: [self-hosted, nix] + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: build + run: nix build -L .#xrefcheck + + - name: test + run: nix build -L .#checks.x86_64-linux.test + + - name: Golden tests (bats) + run: nix shell .#bats .#diffutils .#xrefcheck -c bash -c "cd tests/golden/ && bats ./**" + + - name: windows cross-compilation + run: | + nix build -L .#xrefcheck-windows + echo "WINDOWS_BINARY_PATH=$(readlink -f result)" >> $GITHUB_ENV + + - name: Upload windows executable + uses: actions/upload-artifact@v3 + with: + name: xrefcheck-windows + path: ${{ env.WINDOWS_BINARY_PATH }}/bin/* + + - name: docker-image + run: nix build -L .#docker-image + + - name: static binary + run: | + nix build -L .#xrefcheck-static + echo "STATIC_BINARY_PATH=$(readlink -f result)" >> $GITHUB_ENV + + - name: Upload static binary + uses: actions/upload-artifact@v3 + with: + name: xrefcheck-static + path: ${{ env.STATIC_BINARY_PATH }}/bin/xrefcheck + + - name: Xrefcheck itself + run: nix run . -L diff --git a/.github/workflows/dockerhub-release.yml b/.github/workflows/dockerhub-release.yml new file mode 100644 index 0000000..5531a12 --- /dev/null +++ b/.github/workflows/dockerhub-release.yml @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: 2023 Serokell +# +# SPDX-License-Identifier: MPL-2.0 + +name: dockerhub-release + +on: + push: + tags: + - v[0-9]+.* + +jobs: + dockerhub-release: + runs-on: [self-hosted, nix] + steps: + - uses: actions/checkout@v3 + + - name: Push release image to dockerhub + run: | + export DOCKERHUB_PASSWORD=${{ env.DOCKERHUB_PASSWORD }} + nix build .#docker-image + nix shell .#skopeo -c ./scripts/upload-docker-image.sh "docker-archive:$(readlink result)" "docker://docker.io/serokell/xrefcheck:${{ github.ref_name }}" diff --git a/README.md b/README.md index f9e67c6..6d4391b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ # Xrefcheck -[![Build status](https://badge.buildkite.com/75461331a6058b334383cdfca1071dc1f908b70cf069d857b7.svg?branch=master)](https://buildkite.com/serokell/xrefcheck) +![Build status](https://github.com/serokell/xrefcheck/actions/workflows/ci.yml/badge.svg) Xrefcheck is a tool for verifying local and external references in a repository's documentation that is quick, easy to setup, and suitable to be run on a CI pipeline. diff --git a/flake.nix b/flake.nix index 0d4d27f..58e1d0b 100644 --- a/flake.nix +++ b/flake.nix @@ -12,7 +12,10 @@ pkgs = haskell-nix.legacyPackages.${system}.extend serokell-nix.overlay; flake = (pkgs.haskell-nix.stackProject { - src = ./.; + src = builtins.path { + name = "xrefcheck"; + path = ./.; + }; modules = [{ packages.xrefcheck = { ghcOptions = @@ -84,6 +87,11 @@ checks = { trailing-whitespace = pkgs.build.checkTrailingWhitespace ./.; reuse-lint = pkgs.build.reuseLint ./.; + shellcheck = pkgs.build.shellcheck ./.; + hlint = pkgs.build.haskell.hlint ./.; + stylish-haskell = pkgs.build.haskell.stylish-haskell ./.; + + test = self.packages.${system}."xrefcheck:test:xrefcheck-tests"; }; } ]