Skip to content

Commit

Permalink
Go & integration tests should work now
Browse files Browse the repository at this point in the history
  • Loading branch information
andreev-io committed Jan 23, 2025
1 parent 1a12ba2 commit 8df86f9
Showing 1 changed file with 52 additions and 46 deletions.
98 changes: 52 additions & 46 deletions .github/workflows/kubenetmon.yaml
Original file line number Diff line number Diff line change
@@ -1,81 +1,87 @@
name: kubenetmon
name: CI Workflow

on:
pull_request:
paths:
- '**'
push:
branches:
- main
paths:
- kubenetmon/**
- .github/workflows/kubenetmon.yaml
pull_request:
paths:
- kubenetmon/**
- .github/workflows/kubenetmon.yaml
- '**'

jobs:
lint-and-test:
name: Lint and Test Code and Charts
runs-on: ubuntu-latest
steps:
- name: Check out repository
- name: Check out code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
go-version: '1.23'
cache: true
cache-dependency-path: go.sum

- name: Install dependencies
run: go mod download
run: |
make golangci-lint
- name: Run linting
run: make golangci-lint && make lint
- name: Run code linter
run: |
make lint
- name: Run tests
run: make test && make integration-test
run: |
make test
make integration-test
package-docker:
needs: lint-and-test
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Helm
uses: azure/setup-helm@v4

- name: Build Docker image
- name: Lint Helm charts
run: |
make docker-image
docker tag kubenetmon:latest my-docker-repo/kubenetmon:${{ github.sha }}
helm lint kubenetmon/deploy/helm
- name: Push Docker image
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Test Helm charts
run: |
echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USER}" --password-stdin
docker push my-docker-repo/kubenetmon:${{ github.sha }}
helm template kubenetmon/deploy/helm | kubectl apply --dry-run=client -f -
package-helm:
needs: lint-and-test
build-and-publish:
name: Build and Publish Docker and Helm Chart
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: lint-and-test
steps:
- name: Check out repository
- name: Check out code
uses: actions/checkout@v4

- name: Package Helm chart
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Build Docker image
run: |
helm package kubenetmon/deploy/helm -d packaged-charts
docker build -t your-docker-repo/kubenetmon:${{ github.sha }} .
- name: Push Helm chart
env:
CHART_REPO_URL: ${{ secrets.CHART_REPO_URL }}
CHART_REPO_TOKEN: ${{ secrets.CHART_REPO_TOKEN }}
- name: Push Docker image
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GITHUB_ACTOR }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
docker push your-docker-repo/kubenetmon:${{ github.sha }}
- name: Package Helm chart
run: |
curl -u "token:${CHART_REPO_TOKEN}" \
-F chart=@packaged-charts/kubenetmon-*.tgz \
"${CHART_REPO_URL}"
helm package kubenetmon/deploy/helm
publish:
needs: [package-docker, package-helm]
runs-on: ubuntu-latest
steps:
- name: Deployment successful
run: echo "Docker image and Helm chart published successfully."
- name: Publish Helm chart
uses: helm/[email protected]
with:
charts_dir: kubenetmon/deploy/helm
release_repo: your-helm-repo-url

0 comments on commit 8df86f9

Please sign in to comment.