Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folder refactor and new CI compose test #26

Merged
merged 2 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,31 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@165fe681b849eec43aaa64d786b9ec53e690475f

- name: Start containers
run: docker-compose up --build --force-recreate --detach

- name: Run Tests
run: |
set -x
name=$(docker-compose ps | grep opi-smbios-test | awk '{print $1}')
rc=$(docker wait "${name}")
if [ "${rc}" != "0" ]; then
echo "opi-smbios-test failed:"
docker logs "${name}"
exit 1
fi

- name: Logs
if: always()
run: docker-compose logs

- name: Stop containers
if: always()
run: docker-compose down
2 changes: 2 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ jobs:

- name: Build
run: go build -v -buildmode=plugin ./...
working-directory: cmd

- name: Test
run: go test -race -coverprofile=coverage.out -covermode=atomic -v ./...
working-directory: .

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ COPY go.sum ./
RUN go mod download

# build an app
COPY *.go ./
RUN go build -v -buildmode=plugin -o /opi-smbios-bridge.so ./inventory.go \
&& go build -v -buildmode=default -o /opi-smbios-bridge ./main.go
COPY cmd/ cmd/
COPY pkg/ pkg/
RUN go build -v -buildmode=plugin -o /opi-smbios-bridge.so /app/pkg/... \
&& go build -v -buildmode=default -o /opi-smbios-bridge /app/cmd/...

# second stage to reduce image size
FROM alpine:3.17
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
- "50051:50051"
networks:
- opi
command: go run main.go -port=50051
command: /opi-smbios-bridge -port=50051
healthcheck:
test: grpcurl -plaintext localhost:50051 list || exit 1

Expand Down
File renamed without changes.
File renamed without changes.