Skip to content

test

test #53

Workflow file for this run

name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- ptest
jobs:
validate-pr:
name: Validate PR
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
- name: Verify generated Manifests are up to date
run: make verify-manifests
unit-tests:
name: Unit Tests
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Display build environment
run: printenv
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install Dependencies
run : |
os=$(go env GOOS)
arch=$(go env GOARCH)
curl -L "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/kubebuilder_2.3.1_${os}_${arch}.tar.gz" | tar -xz -C /tmp/
sudo mv /tmp/kubebuilder_2.3.1_${os}_${arch} /usr/local/kubebuilder
export PATH=$PATH:/usr/local/kubebuilder/bin
- name: Run tests
run: |
make generate manifests
go test ./... -v -coverprofile cover.out -covermode=atomic
unit-test-ppc64le:
name: Unit Test ppc64le
runs-on: ubuntu-22.04
strategy:
matrix:
platform: [ppc64le]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Display build environment
run: printenv
- name: Install required packages
run : |
os=linux
arch=${{ matrix.platform }}
curl -L "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/kubebuilder_2.3.1_${os}_${arch}.tar.gz" | tar -xz -C /tmp/
sudo mv /tmp/kubebuilder_2.3.1_${os}_${arch} /usr/local/kubebuilder
curl -L "https://github.com/etcd-io/etcd/releases/download/v3.5.11/etcd-v3.5.11-${os}-${arch}.tar.gz" | tar -xz -C /tmp/
sudo mv /tmp/etcd-v3.5.11-${os}-${arch}/etcd /usr/local/kubebuilder/bin
curl -L "https://storage.googleapis.com/kubernetes-release/release/v1.24.13/kubernetes-server-${os}-${arch}.tar.gz" | tar -xz -C /tmp/
sudo mv /tmp/kubernetes/server/bin/kube-apiserver /usr/local/kubebuilder/bin
sudo mv /tmp/kubernetes/server/bin/kubectl /usr/local/kubebuilder/bin
- name: Run tests on ${{ matrix.platform }}
run: >-
docker run \
--rm \
--platform linux/ppc64le \
--mount "type=bind,src=/usr/local/kubebuilder,target=/usr/local/kubebuilder" \
-w /build \
golang:1.20 \
/bin/bash -ec '\
useradd testuser; \
chown testuser $(pwd); \
su testuser -c "git clone https://github.com/project-koku/koku-metrics-operator.git && \
cd koku-metrics-operator && make generate manifests && go test ./... -v -coverprofile cover.out -covermode=atomic";'
# - name: Upload test coverage file
# uses: actions/upload-artifact@v4
# with:
# name: coverage
# path: cover.out
# coverage:
# name: Coverage
# needs: unit-tests
# runs-on: ubuntu-22.04
# steps:
#
# - name: Checkout
# # this checkout is required for the coverage report. If we don't do this, then
# # the uploaded report is invalid and codecov doesn't know how to process it.
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
#
# - name: Download coverage result from unit-tests
# uses: actions/download-artifact@v4
# with:
# name: coverage
#
# - name: Upload coverage
# uses: codecov/codecov-action@v3
# with:
# file: ./cover.out
# flags: unittests
# token: ${{ secrets.CODECOV_TOKEN }}
# fail_ci_if_error: true
#
# sonarcloud:
# name: SonarCloud
# needs: [validate-pr,unit-tests]
# runs-on: ubuntu-20.04
# steps:
#
# - name: Checkout
# # this checkout is required for the coverage report. If we don't do this, then
# # the uploaded report is invalid and codecov doesn't know how to process it.
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
#
# - name: Download coverage result from unit-tests
# uses: actions/download-artifact@v4
# with:
# name: coverage
#
# - name: SonarCloud Scan
# uses: SonarSource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}