diff --git a/.github/workflows/release-freebsd.yaml b/.github/workflows/release-freebsd.yaml deleted file mode 100644 index baaf5fa..0000000 --- a/.github/workflows/release-freebsd.yaml +++ /dev/null @@ -1,83 +0,0 @@ -# compiles FreeBSD artifacts and attaches them to build -name: Release FreeBSD - -on: - release: - # Only use the types keyword to narrow down the activity types that will trigger your workflow. - types: [published] - workflow_dispatch: - inputs: - tag_name: - description: 'tag to build artifacts for' - required: true - default: 'v0.0.0' -jobs: - - release-freebsd: - name: Release FreeBSD - runs-on: macos-10.15 - env: - PROJECT_PATH: /go/src/github.com/analogj/scrutiny - GOPATH: /go - GOOS: freebsd - GOARCH: amd64 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - ref: ${{github.event.release.tag_name || github.event.inputs.tag_name }} - - name: Build Binaries - uses: vmactions/freebsd-vm@v0.1.5 - with: - envs: 'PROJECT_PATH GOPATH GOOS GOARCH' - usesh: true - #TODO: lock go version using https://www.jeremymorgan.com/tutorials/golang/how-to-install-go-freebsd/ - prepare: pkg install -y curl go gmake - run: | - pwd - ls -lah - whoami - freebsd-version - - mkdir -p $(dirname "$PROJECT_PATH") - cp -R $GITHUB_WORKSPACE $PROJECT_PATH - cd $PROJECT_PATH - - mkdir -p $GITHUB_WORKSPACE/dist - - echo "building web binary (OS = ${GOOS}, ARCH = ${GOARCH})" - go build -ldflags "-extldflags=-static -X main.goos=${GOOS} -X main.goarch=${GOARCH}" -o $GITHUB_WORKSPACE/dist/scrutiny-web-${GOOS}-${GOARCH} -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go - - chmod +x "$GITHUB_WORKSPACE/dist/scrutiny-web-${GOOS}-${GOARCH}" - file "$GITHUB_WORKSPACE/dist/scrutiny-web-${GOOS}-${GOARCH}" || true - ldd "$GITHUB_WORKSPACE/dist/scrutiny-web-${GOOS}-${GOARCH}" || true - - echo "building collector binary (OS = ${GOOS}, ARCH = ${GOARCH})" - go build -ldflags "-extldflags=-static -X main.goos=${GOOS} -X main.goarch=${GOARCH}" -o $GITHUB_WORKSPACE/dist/scrutiny-collector-metrics-${GOOS}-${GOARCH} -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go - - chmod +x "$GITHUB_WORKSPACE/dist/scrutiny-collector-metrics-${GOOS}-${GOARCH}" - file "$GITHUB_WORKSPACE/dist/scrutiny-collector-metrics-${GOOS}-${GOARCH}" || true - ldd "$GITHUB_WORKSPACE/dist/scrutiny-collector-metrics-${GOOS}-${GOARCH}" || true - - - name: Release Asset - Collector - freebsd-amd64 - id: upload-release-asset2 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: './dist/scrutiny-collector-metrics-freebsd-amd64' - asset_name: scrutiny-collector-metrics-freebsd-amd64 - asset_content_type: application/octet-stream - - - name: Release Asset - Web - freebsd-amd64 - id: upload-release-asset1 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: './dist/scrutiny-web-freebsd-amd64' - asset_name: scrutiny-web-freebsd-amd64 - asset_content_type: application/octet-stream - diff --git a/.github/workflows/release-frontend.yaml b/.github/workflows/release-frontend.yaml index 1ef261b..4f9aecf 100644 --- a/.github/workflows/release-frontend.yaml +++ b/.github/workflows/release-frontend.yaml @@ -19,11 +19,7 @@ jobs: run: "cd webapp/frontend && ./git.version.sh" - name: Build Frontend run: | - cd webapp/frontend - npm install -g @angular/cli@9.1.4 - npm install - mkdir -p dist - npm run build:prod -- --output-path=dist + make binary-frontend tar -czf scrutiny-web-frontend.tar.gz dist - name: Upload Frontend Asset id: upload-release-asset3 @@ -32,6 +28,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: './webapp/frontend/scrutiny-web-frontend.tar.gz' + asset_path: './scrutiny-web-frontend.tar.gz' asset_name: scrutiny-web-frontend.tar.gz asset_content_type: application/gzip diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 103ad32..2a44423 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -13,10 +13,10 @@ on: default: 'webapp/backend/pkg/version/version.go' jobs: - build: - name: Build + release: + name: Create Release Commit runs-on: ubuntu-latest - container: techknowlogick/xgo:go-1.17.x + container: ghcr.io/packagrio/packagr:latest-golang # Service containers to run with `build` (Required for end-to-end testing) services: influxdb: @@ -31,8 +31,7 @@ jobs: ports: - 8086:8086 env: - PROJECT_PATH: /go/src/github.com/analogj/scrutiny - CGO_ENABLED: 1 + STATIC: true steps: - name: Git run: | @@ -53,34 +52,80 @@ jobs: GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} # Leave this line unchanged - name: Test run: | - mkdir -p $(dirname "$PROJECT_PATH") - cp -a $GITHUB_WORKSPACE $PROJECT_PATH - cd $PROJECT_PATH - - go mod vendor - go test -v -tags "static" $(go list ./... | grep -v /vendor/) - - - name: Build Binaries - run: | - - cd $PROJECT_PATH - make all - - # restore modified dir to GH workspace. - cp -arf $PROJECT_PATH/. $GITHUB_WORKSPACE/ - - # copy all the build artifacts to the GH workspace - cp -arf /build/. $GITHUB_WORKSPACE/ - - - name: Commit Changes + make binary-clean binary-test-coverage + - name: Commit Changes Locally id: commit uses: packagrio/action-releasr-go@master env: - # This is necessary in order to push a commit to the repo GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} # Leave this line unchanged with: version_metadata_path: ${{ github.event.inputs.version_metadata_path }} - - name: Publish Release + - name: Upload workspace + uses: actions/upload-artifact@v3 + with: + name: workspace + path: ${{ github.workspace }}/**/* + retention-days: 1 + + build: + name: Build ${{ matrix.cfg.goos }}/${{ matrix.cfg.goarch }}${{ matrix.cfg.goarm }} + needs: release + runs-on: ${{ matrix.cfg.on }} + env: + GOOS: ${{ matrix.cfg.goos }} + GOARCH: ${{ matrix.cfg.goarch }} + GOARM: ${{ matrix.cfg.goarm }} + STATIC: true + strategy: + matrix: + cfg: + - { on: ubuntu-latest, goos: linux, goarch: amd64 } + - { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 5 } + - { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 6 } + - { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 7 } + - { on: ubuntu-latest, goos: linux, goarch: arm64 } + - { on: macos-latest, goos: darwin, goarch: amd64 } + - { on: macos-latest, goos: darwin, goarch: arm64 } + - { on: macos-latest, goos: freebsd, goarch: amd64 } + - { on: windows-latest, goos: windows, goarch: amd64 } + - { on: windows-latest, goos: windows, goarch: arm64 } + steps: + - name: Download workspace + uses: actions/download-artifact@v3 + with: + name: workspace + - uses: actions/setup-go@v3 + with: + go-version: '1.18.3' # The Go version to download (if necessary) and use. + - name: Build Binaries + run: | + make binary-clean binary-all + - name: Archive + uses: actions/upload-artifact@v2 + with: + name: binaries.zip + path: | + scrutiny-web-* + scrutiny-collector-metrics-* + + release-publish: + name: Publish Release + needs: build + runs-on: ubuntu-latest + steps: + - name: Download workspace + uses: actions/download-artifact@v3 + with: + name: workspace + - name: Download binaries + uses: actions/download-artifact@v3 + with: + name: binaries.zip + - name: List + shell: bash + run: | + ls -alt + - name: Publish Release & Assets id: publish uses: packagrio/action-publishr-go@master env: @@ -89,15 +134,23 @@ jobs: with: version_metadata_path: ${{ github.event.inputs.version_metadata_path }} upload_assets: - scrutiny-web-linux-amd64 + scrutiny-collector-metrics-darwin-amd64 + scrutiny-collector-metrics-darwin-arm64 + scrutiny-collector-metrics-freebsd-amd64 scrutiny-collector-metrics-linux-amd64 - scrutiny-web-linux-arm64 + scrutiny-collector-metrics-linux-arm-5 + scrutiny-collector-metrics-linux-arm-6 + scrutiny-collector-metrics-linux-arm-7 scrutiny-collector-metrics-linux-arm64 + scrutiny-collector-metrics-windows-amd64.exe + scrutiny-collector-metrics-windows-arm64.exe + scrutiny-web-darwin-amd64 + scrutiny-web-darwin-arm64 + scrutiny-web-freebsd-amd64 + scrutiny-web-linux-amd64 scrutiny-web-linux-arm-5 - scrutiny-collector-metrics-linux-arm-5 scrutiny-web-linux-arm-6 - scrutiny-collector-metrics-linux-arm-6 scrutiny-web-linux-arm-7 - scrutiny-collector-metrics-linux-arm-7 - scrutiny-web-windows-4.0-amd64.exe - scrutiny-collector-metrics-windows-4.0-amd64.exe + scrutiny-web-linux-arm64 + scrutiny-web-windows-amd64.exe + scrutiny-web-windows-arm64.exe diff --git a/Makefile b/Makefile index fc70739..afb2d84 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,8 @@ all: binary-all .PHONY: binary-all binary-all: binary-collector binary-web - @echo "building all" + @echo "built binary-collector and binary-web targets" + .PHONY: binary-clean binary-clean: @@ -58,8 +59,6 @@ binary-clean: .PHONY: binary-dep binary-dep: - env - go env go mod vendor .PHONY: binary-test @@ -102,7 +101,11 @@ binary-frontend: npm run build:prod -- --output-path=$(CURDIR)/dist -############# +######################################################################################################################## +# Docker +# NOTE: these docker make targets are only used for local development (not used by Github Actions/CI) +# NOTE: docker-web and docker-omnibus require `make binary-frontend` or frontend.tar.gz content in /dist before executing. +######################################################################################################################## .PHONY: docker-collector docker-collector: @echo "building collector docker image" diff --git a/README.md b/README.md index 6871fe7..1360f49 100644 --- a/README.md +++ b/README.md @@ -232,18 +232,18 @@ scrutiny-collector-metrics run --debug --log-file /tmp/collector.log # Supported Architectures - | Architecture Name | Binaries | Docker | | --- | --- | --- | -| amd64 | :white_check_mark: | :white_check_mark: | -| arm-5 | :white_check_mark: | | -| arm-6 | :white_check_mark: | | -| arm-7 | :white_check_mark: | web/collector only. see [#236](https://github.com/AnalogJ/scrutiny/issues/236) | -| arm64 | :white_check_mark: | :white_check_mark: | -| freebsd | collector only. see [#238](https://github.com/AnalogJ/scrutiny/issues/238) | | +| linux-amd64 | :white_check_mark: | :white_check_mark: | +| linux-arm-5 | :white_check_mark: | | +| linux-arm-6 | :white_check_mark: | | +| linux-arm-7 | :white_check_mark: | web/collector only. see [#236](https://github.com/AnalogJ/scrutiny/issues/236) | +| linux-arm64 | :white_check_mark: | :white_check_mark: | +| freebsd-amd64 | collector only. see [#238](https://github.com/AnalogJ/scrutiny/issues/238) | | | macos-amd64 | | :white_check_mark: | | macos-arm64 | | :white_check_mark: | | windows-amd64 | :white_check_mark: | WIP, see [#15](https://github.com/AnalogJ/scrutiny/issues/15) | +| windows-arm64 | :white_check_mark: | | # Contributing diff --git a/docker/Dockerfile b/docker/Dockerfile index c097618..ff7476f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,14 +1,16 @@ +######################################################################################################################## +# Omnibus Image +# NOTE: this image requires the `make binary-frontend` target to have been run before `docker build` The `dist` directory must exist. +######################################################################################################################## + + ######## FROM golang:1.17-bullseye as backendbuild WORKDIR /go/src/github.com/analogj/scrutiny - COPY . /go/src/github.com/analogj/scrutiny +RUN make binary-clean binary-all WEB_BINARY_NAME=scrutiny -RUN go mod vendor && \ - go build -o scrutiny webapp/backend/cmd/scrutiny/scrutiny.go && \ - go build -o scrutiny-collector-selftest collector/cmd/collector-selftest/collector-selftest.go && \ - go build -o scrutiny-collector-metrics collector/cmd/collector-metrics/collector-metrics.go ######## FROM debian:bullseye-slim as runtime @@ -27,18 +29,16 @@ RUN apt-get update && apt-get install -y cron smartmontools ca-certificates curl && curl https://github.com/just-containers/s6-overlay/releases/download/v1.21.8.0/s6-overlay-${S6_ARCH}.tar.gz -L -s --output /tmp/s6-overlay-${S6_ARCH}.tar.gz \ && tar xzf /tmp/s6-overlay-${S6_ARCH}.tar.gz -C / \ && rm -rf /tmp/s6-overlay-${S6_ARCH}.tar.gz \ - && curl -L https://dl.influxdata.com/influxdb/releases/influxdb2-2.2.0-${TARGETARCH}.deb --output /tmp/influxdb2-2.2.0-${TARGETARCH}.deb \ + && curl -L https://dl.influxdata.com/influxdb/relekeyases/influxdb2-2.2.0-${TARGETARCH}.deb --output /tmp/influxdb2-2.2.0-${TARGETARCH}.deb \ && dpkg -i --force-all /tmp/influxdb2-2.2.0-${TARGETARCH}.deb COPY /rootfs / COPY /rootfs/etc/cron.d/scrutiny /etc/cron.d/scrutiny COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny /opt/scrutiny/bin/ -COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-selftest /opt/scrutiny/bin/ COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-metrics /opt/scrutiny/bin/ COPY dist /opt/scrutiny/web RUN chmod +x /opt/scrutiny/bin/scrutiny && \ - chmod +x /opt/scrutiny/bin/scrutiny-collector-selftest && \ chmod +x /opt/scrutiny/bin/scrutiny-collector-metrics && \ chmod 0644 /etc/cron.d/scrutiny && \ rm -f /etc/cron.daily/* && \ diff --git a/docker/Dockerfile.collector b/docker/Dockerfile.collector index 18d5d6f..9c614f8 100644 --- a/docker/Dockerfile.collector +++ b/docker/Dockerfile.collector @@ -1,3 +1,8 @@ +######################################################################################################################## +# Collector Image +######################################################################################################################## + + ######## FROM golang:1.17-bullseye as backendbuild @@ -5,9 +10,7 @@ WORKDIR /go/src/github.com/analogj/scrutiny COPY . /go/src/github.com/analogj/scrutiny -RUN go mod vendor && \ - go build -ldflags '-w -extldflags "-static"' -o scrutiny-collector-selftest collector/cmd/collector-selftest/collector-selftest.go && \ - go build -ldflags '-w -extldflags "-static"' -o scrutiny-collector-metrics collector/cmd/collector-metrics/collector-metrics.go +RUN make binary-clean binary-collector ######## FROM debian:bullseye-slim as runtime @@ -18,10 +21,8 @@ RUN apt-get update && apt-get install -y cron smartmontools ca-certificates tzda COPY /docker/entrypoint-collector.sh /entrypoint-collector.sh COPY /rootfs/etc/cron.d/scrutiny /etc/cron.d/scrutiny -COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-selftest /opt/scrutiny/bin/ COPY --from=backendbuild /go/src/github.com/analogj/scrutiny/scrutiny-collector-metrics /opt/scrutiny/bin/ -RUN chmod +x /opt/scrutiny/bin/scrutiny-collector-selftest && \ - chmod +x /opt/scrutiny/bin/scrutiny-collector-metrics && \ +RUN chmod +x /opt/scrutiny/bin/scrutiny-collector-metrics && \ chmod +x /entrypoint-collector.sh && \ chmod 0644 /etc/cron.d/scrutiny && \ rm -f /etc/cron.daily/apt /etc/cron.daily/dpkg /etc/cron.daily/passwd diff --git a/docker/Dockerfile.web b/docker/Dockerfile.web index 73650a9..ff03115 100644 --- a/docker/Dockerfile.web +++ b/docker/Dockerfile.web @@ -1,3 +1,9 @@ +######################################################################################################################## +# Web Image +# NOTE: this image requires the `make binary-frontend` target to have been run before `docker build` The `dist` directory must exist. +######################################################################################################################## + + ######## FROM golang:1.17-bullseye as backendbuild @@ -5,8 +11,8 @@ WORKDIR /go/src/github.com/analogj/scrutiny COPY . /go/src/github.com/analogj/scrutiny -RUN go mod vendor && \ - go build -o scrutiny webapp/backend/cmd/scrutiny/scrutiny.go +RUN make binary-clean binary-all WEB_BINARY_NAME=scrutiny + ######## FROM debian:bullseye-slim as runtime diff --git a/docs/TESTERS.md b/docs/TESTERS.md new file mode 100644 index 0000000..088beba --- /dev/null +++ b/docs/TESTERS.md @@ -0,0 +1,20 @@ +# Testers + +Scrutiny supports many operating systems, CPU architectures and runtime environments. Unfortunately that makes it incredibly +difficult to test. +Thankfully the following users have been gracious enough to test/validate Scrutiny works on their system. + +> NOTE: If you're interested in volunteering to test Scrutiny beta builds on your system, please [open an issue](https://github.com/AnalogJ/scrutiny/issues). + +| Architecture Name | Binaries | Docker | +| --- | --- | --- | +| linux-amd64 | -- | @feroxy @rshxyz | +| linux-arm-5 | -- | | +| linux-arm-6 | -- | | +| linux-arm-7 | @Zorlin | @martini1992 | +| linux-arm64 | @SiM22 @Zorlin | @ViRb3 @agneevX @benamajin | +| freebsd-amd64 | @BadCo-NZ @varunsridharan @martadinata666 @KenwoodFox @FingerlessGlov3s | | +| macos-amd64 | -- | -- | +| macos-arm64 | -- | -- | +| windows-amd64 | @gabrielv33 | -- | +| windows-arm64 | -- | -- | \ No newline at end of file diff --git a/go.mod b/go.mod index d13ec40..91e6062 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.17 require ( github.com/analogj/go-util v0.0.0-20190301173314-5295e364eb14 - github.com/citilinkru/libudev v1.0.0 github.com/containrrr/shoutrrr v0.4.4 github.com/fatih/color v1.10.0 github.com/gin-gonic/gin v1.6.3 @@ -24,6 +23,7 @@ require ( require ( github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect + github.com/citilinkru/libudev v1.0.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deepmap/oapi-codegen v1.8.2 // indirect