Skip to content

Commit

Permalink
Merge branch 'master' into yamllint
Browse files Browse the repository at this point in the history
  • Loading branch information
dklimpel authored Aug 29, 2024
2 parents b8968fa + 02d6c53 commit f73a2a9
Show file tree
Hide file tree
Showing 21 changed files with 225 additions and 69 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/docker-goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,32 @@ jobs:
ghcr.io/${{ github.repository_owner }}/goss
- name: Get latest git tag
uses: actions-ecosystem/action-get-latest-tag@v1
if: github.ref_name == 'master'
id: get-latest-tag
run: |
# source: https://github.com/actions-ecosystem/action-get-latest-tag/blob/main/entrypoint.sh
set -e
git config --global --add safe.directory /github/workspace
git fetch --tags --force
# This suppress an error occurred when the repository is a complete one.
git fetch --prune --unshallow 2>/dev/null || true
latest_tag=$(git describe --abbrev=0 --tags || true)
echo "tag=${latest_tag}" >> "$GITHUB_OUTPUT"
echo "Latest tag: $latest_tag"
- name: Set short git commit SHA
if: github.ref_name == 'master'
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
echo "COMMIT_SHORT_SHA: $calculatedSha"
- name: Get the current version of Go from project.
run: echo "GO_VERSION_FROM_PROJECT=$(go mod edit -json | jq -r .Go)" >> $GITHUB_ENV

- name: Build master goss image
if: github.ref_name == 'master'
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
build-args: |
GO_VERSION=${{ env.GO_VERSION_FROM_PROJECT }}
Expand All @@ -72,7 +84,7 @@ jobs:

- name: Build release goss image
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
build-args: |
GO_VERSION=${{ env.GO_VERSION_FROM_PROJECT }}
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/docker-integration-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Docker images for integration tests

on:
# push:

Check warning on line 4 in .github/workflows/docker-integration-tests.yaml

View workflow job for this annotation

GitHub Actions / validate-yaml

4:1 [comments-indentation] comment not indented like content
# branches:
# - master
workflow_dispatch:

env:
PLATFORMS: "linux/amd64"

jobs:
list-dockerfiles:
name: Create list of existing dockerfiles
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get file list
id: set-matrix
run: |
# lists all Dockerfile_* and ignore (grep) files with extension (e.g. *.md5)
# tranforms the file list in JSON array (StackOverflow#10234327)
# converts the list into objects of dockerfile and image name
ls integration-tests/Dockerfile_* |
grep -Ev "\..{0,3}$" |
jq -R -s 'split("\n")[:-1]' |
jq '. | map({dockerfile: ., image: sub(".*_"; "")})' > filelist.json
echo "matrix=$(jq -c . filelist.json)" >> "$GITHUB_OUTPUT"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

docker:
needs: [list-dockerfiles]
name: Build and push Docker image
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.list-dockerfiles.outputs.matrix) }}
permissions:
packages: write
contents: read

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: MD5 of Dockerfile
id: md5_result
run: |
echo "md5=$(md5sum "${{ matrix.dockerfile }}" | awk '{ print $1 }')" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}
labels: |
rocks.goss.dockerfile-md5=${{ steps.md5_result.outputs.md5 }}
- name: Build and push tag
uses: docker/build-push-action@v5
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}:latest
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ env.PLATFORMS }}
18 changes: 15 additions & 3 deletions .github/workflows/golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,27 @@ jobs:
- name: Unit tests and coverage
run: make cov

integartion-test:
integration-test:
needs: [coverage]
name: Integration tests
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Integration tests
run: make test-int-all
shell: bash
run: |
os_name="$(go env GOOS)"
if [[ "${os_name}" == "darwin" || "${os_name}" == "windows" ]]; then
make "test-int-${os_name}-all"
else
# linux runs all tests;
make test-int-all
fi
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
language: go

go:
- 1.21.x
- 1.22.x

os:
- osx
Expand Down
38 changes: 19 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
ARG GO_VERSION=1.21

FROM docker.io/golang:${GO_VERSION}-alpine AS base

ARG GOSS_VERSION=v0.0.0
WORKDIR /build

RUN --mount=target=. \
CGO_ENABLED=0 go build \
-ldflags "-X github.com/goss-org/goss/util.Version=${GOSS_VERSION} -s -w" \
-o "/release/goss" \
./cmd/goss

FROM alpine:3.19

COPY --from=base /release/* /usr/bin/

RUN mkdir /goss
VOLUME /goss
ARG GO_VERSION=1.22

FROM docker.io/golang:${GO_VERSION}-alpine AS base

ARG GOSS_VERSION=v0.0.0
WORKDIR /build

RUN --mount=target=. \
CGO_ENABLED=0 go build \
-ldflags "-X github.com/goss-org/goss/util.Version=${GOSS_VERSION} -s -w" \
-o "/release/goss" \
./cmd/goss

FROM alpine:3.19

COPY --from=base /release/* /usr/bin/

RUN mkdir /goss
VOLUME /goss
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ This will install goss and [dgoss](https://github.com/goss-org/goss/tree/master/
# Install latest version to /usr/local/bin
curl -fsSL https://goss.rocks/install | sh

# Install v0.3.16 version to ~/bin
curl -fsSL https://goss.rocks/install | GOSS_VER=v0.3.16 GOSS_DST=~/bin sh
# Install v0.4.8 version to ~/bin
curl -fsSL https://goss.rocks/install | GOSS_VER=v0.4.8 GOSS_DST=~/bin sh
```

<!-- --8<-- [end:intro] -->
Expand All @@ -73,12 +73,12 @@ chmod +rx /usr/local/bin/dgoss

```bash
# See https://github.com/goss-org/goss/releases for release versions
VERSION=v0.3.10
VERSION=v0.4.8
curl -L "https://github.com/goss-org/goss/releases/download/${VERSION}/goss-linux-amd64" -o /usr/local/bin/goss
chmod +rx /usr/local/bin/goss

# (optional) dgoss docker wrapper (use 'master' for latest version)
VERSION=v0.3.10
VERSION=v0.4.8
curl -L "https://github.com/goss-org/goss/releases/download/${VERSION}/dgoss" -o /usr/local/bin/dgoss
chmod +rx /usr/local/bin/dgoss
```
Expand All @@ -93,11 +93,11 @@ make build

## Full Documentation

[Full Documentation](https://github.com/goss-org/goss/blob/e73553f9c3065ac297499dafb4f8abef6acb24ad/docs/manual.md)
[Full Documentation](https://goss.readthedocs.io/en/stable/)

## Using the container image

[Using the Goss container image](docs/container_image.md)
[Using the Goss container image](https://goss.readthedocs.io/en/stable/container_image/)

## Quick start

Expand Down
5 changes: 4 additions & 1 deletion development/build_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -xeu

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
INTEGRATION_TEST_DIR="$SCRIPT_DIR/../integration-tests/"
CONTAINER_REPOSITORY="aelsabbahy"

LABEL_DATE=$(date -u +'%Y-%m-%dT%H:%M:%S.%3NZ')
LABEL_URL="https://github.com/goss-org/goss"
Expand All @@ -12,6 +13,7 @@ LABEL_REVISION=$(git rev-parse HEAD)
for docker_file in $INTEGRATION_TEST_DIR/Dockerfile_*; do
[[ $docker_file == *.md5 ]] && continue
os=$(cut -d '_' -f2 <<<"$docker_file")
md5=$(md5sum "$docker_file" | awk '{ print $1 }')
docker build \
--label "org.opencontainers.image.created=$LABEL_DATE" \
--label "org.opencontainers.image.description=Quick and Easy server testing/validation" \
Expand All @@ -21,5 +23,6 @@ for docker_file in $INTEGRATION_TEST_DIR/Dockerfile_*; do
--label "org.opencontainers.image.title=goss" \
--label "org.opencontainers.image.url=$LABEL_URL" \
--label "org.opencontainers.image.version=manual" \
-t "aelsabbahy/goss_${os}:latest" - < "$docker_file"
--label "rocks.goss.dockerfile-md5"=$md5 \
-t "$CONTAINER_REPOSITORY/goss_${os}:latest" - < "$docker_file"
done
3 changes: 2 additions & 1 deletion development/push_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
set -xeu

SCRIPT_DIR=$(readlink -f "$(dirname "$0")")
images=$(docker images | grep '^aelsabbahy/goss_.*latest' | awk '$0=$1')
CONTAINER_REPOSITORY="aelsabbahy"
images=$(docker images | grep "^$CONTAINER_REPOSITORY/goss_.*latest" | awk '$0=$1')

# Use md5sum to determine if CI needs to do a docker build
pushd "$SCRIPT_DIR/../integration-tests";
Expand Down
4 changes: 2 additions & 2 deletions extras/dgoss/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Since goss runs on the target container, dgoss can be used on a Mac OSX system b
curl -L https://raw.githubusercontent.com/goss-org/goss/master/extras/dgoss/dgoss -o /usr/local/bin/dgoss
chmod +rx /usr/local/bin/dgoss

# Download desired goss version to your preferred location (e.g. v0.3.6)
curl -L https://github.com/goss-org/goss/releases/download/v0.3.6/goss-linux-amd64 -o ~/Downloads/goss-linux-amd64
# Download desired goss version to your preferred location (e.g. v0.4.8)
curl -L https://github.com/goss-org/goss/releases/download/v0.4.8/goss-linux-amd64 -o ~/Downloads/goss-linux-amd64

# Set your GOSS_PATH to the above location
export GOSS_PATH=~/Downloads/goss-linux-amd64
Expand Down
2 changes: 1 addition & 1 deletion extras/kgoss/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ chmod a+rx "${dest_dir}/kgoss"

## install goss
if [[ ! $(which jq) ]]; then echo "jq is required, get from https://stedolan.github.io/jq"; fi
version=v0.3.8
version=v0.4.8
arch=amd64
host=github.com
# for private repos, leave `host` blank or same as above:
Expand Down
39 changes: 20 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
module github.com/goss-org/goss

go 1.21
go 1.22

require (
github.com/Masterminds/sprig/v3 v3.2.3
github.com/achanda/go-sysctl v0.0.0-20160222034550-6be7678c45d2
github.com/blang/semver/v4 v4.0.0
github.com/cheekybits/genny v1.0.0
github.com/fatih/color v1.16.0
github.com/fatih/color v1.17.0
github.com/goss-org/GOnetstat v0.0.0-20230101144325-22be0bd9e64d
github.com/goss-org/go-ps v0.0.0-20230609005227-7b318e6a56e5
github.com/hashicorp/logutils v1.0.0
github.com/miekg/dns v1.1.58
github.com/miekg/dns v1.1.61
github.com/moby/sys/mountinfo v0.7.1
github.com/oleiade/reflections v1.0.1
github.com/onsi/gomega v1.33.1
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pmezard/go-difflib v1.0.0
github.com/prometheus/client_golang v1.19.0
github.com/prometheus/common v0.50.0
github.com/samber/lo v1.39.0
github.com/prometheus/client_golang v1.19.1
github.com/prometheus/common v0.55.0
github.com/samber/lo v1.46.0
github.com/stretchr/testify v1.9.0
github.com/tidwall/gjson v1.17.1
github.com/urfave/cli v1.22.14
Expand All @@ -31,31 +31,32 @@ require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240716160929-1d5bc16f04a8 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/tools v0.20.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/tools v0.23.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
)
Loading

0 comments on commit f73a2a9

Please sign in to comment.