feat: Build Windows images #4786
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Push/PR pipeline | |
on: | |
pull_request: | |
branches-ignore: | |
- v2 | |
push: | |
branches: | |
- main | |
- renovate/** | |
jobs: | |
build: | |
name: Build integration for | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [ linux ] | |
goarch: [ amd64, arm64, arm ] | |
include: | |
- goos: windows | |
goarch: amd64 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
- name: Build integration | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
run: | | |
make compile | |
- name: Upload artifact for docker build step | |
uses: actions/upload-artifact@v4 | |
with: | |
retention-days: 1 | |
name: nri-kubernetes-${{ matrix.goos }}-${{ matrix.goarch }} | |
path: bin/nri-kubernetes-${{ matrix.goos }}-${{ matrix.goarch }} | |
docker-windows: | |
name: Docker image for | |
needs: [ build ] | |
strategy: | |
matrix: | |
include: | |
- runsOn: windows-2019 | |
baseImageTag: ltsc2019-amd64 | |
- runsOn: windows-2022 | |
baseImageTag: ltsc2022-amd64 | |
runs-on: ${{ matrix.runsOn }} | |
steps: | |
- name: Download all artifacts from build job | |
uses: actions/download-artifact@v4 | |
with: | |
path: bin | |
- name: Docker Build | |
run: | | |
docker build --file Dockerfile.windows --build-arg BASE_IMAGE_TAG=${{ matrix.baseImageTag }} -t nri-kubernetes:windows-${{ matrix.baseImageTag }} . | |
docker save nri-kubernetes:windows-${{ matrix.baseImageTag }} > nri-kubernetes-${{ matrix.baseImageTag }}.tar | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nri-kubernetes-${{ matrix.baseImageTag }} | |
path: nri-kubernetes-${{ matrix.baseImageTag }}.tar | |
chart-lint: | |
name: Helm chart Lint | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
kubernetes-version: ["v1.31.0", "v1.30.0", "v1.29.5", "v1.28.3", "v1.27.5"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: helm/[email protected] | |
- uses: azure/setup-helm@v4 | |
with: | |
version: 'v3.0.0' | |
- name: Lint charts | |
run: ct --config .github/ct.yaml lint --debug | |
- name: Check for changed installable charts | |
id: list-changed | |
run: | | |
changed=$(ct --config .github/ct.yaml list-changed) | |
if [[ -n "$changed" ]]; then | |
echo "changed=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Run helm unit tests | |
if: steps.list-changed.outputs.changed == 'true' | |
run: | | |
helm plugin install https://github.com/helm-unittest/helm-unittest --version=0.3.1 | |
for chart in $(ct --config .github/ct.yaml list-changed); do | |
if [ -d "$chart/tests/" ]; then | |
helm unittest $chart | |
else | |
echo "No unit tests found for $chart" | |
fi | |
done | |
- name: Setup Minikube | |
uses: manusa/[email protected] | |
if: steps.list-changed.outputs.changed == 'true' | |
with: | |
minikube version: v1.34.0 | |
kubernetes version: ${{ matrix.kubernetes-version }} | |
github token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/setup-go@v5 | |
if: steps.list-changed.outputs.changed == 'true' | |
with: | |
go-version-file: 'go.mod' | |
- name: Create image for chart testing | |
if: steps.list-changed.outputs.changed == 'true' | |
run: | | |
GOOS=linux GOARCH=amd64 make compile | |
DOCKER_BUILDKIT=1 docker build -t e2e/nri-kubernetes:test . | |
minikube image load e2e/nri-kubernetes:test | |
kubectl create ns ct | |
- name: Test install charts | |
if: steps.list-changed.outputs.changed == 'true' | |
run: ct install --namespace ct --config .github/ct.yaml --debug | |
- name: Test upgrade charts | |
if: steps.list-changed.outputs.changed == 'true' | |
run: ct install --namespace ct --config .github/ct.yaml --debug --upgrade | |
test: | |
name: Run tests | |
needs: [ build ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
- name: Run tests | |
run: make test | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7 | |
with: | |
fail_ci_if_error: false | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
static-analysis: | |
name: Static analysis and linting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
- uses: newrelic/newrelic-infra-checkers@v1 | |
with: | |
golangci-lint-config: golangci-lint | |
# - name: Semgrep | |
# uses: returntocorp/semgrep-action@v1 | |
# with: | |
# auditOn: push | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v6 | |
continue-on-error: ${{ github.event_name != 'pull_request' }} | |
with: | |
only-new-issues: true | |
codespell: | |
name: Codespell | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Codespell test | |
uses: codespell-project/actions-codespell@master | |
with: | |
ignore_words_list: enver,NotIn |