# # Copyright (c) 2019-2023 Red Hat, Inc. # This program and the accompanying materials are made # available under the terms of the Eclipse Public License 2.0 # which is available at https://www.eclipse.org/legal/epl-2.0/ # # SPDX-License-Identifier: EPL-2.0 # # Contributors: # Red Hat, Inc. - initial API and implementation # name: PR check on: pull_request jobs: unit-tests: runs-on: ubuntu-22.04 steps: - name: Checkout source code uses: actions/checkout@v3 - name: Set up Go 1.19 uses: actions/setup-go@v3 with: go-version: 1.19.13 - name: Run unit tests run: make test image-build: runs-on: ubuntu-22.04 steps: - name: Checkout source code uses: actions/checkout@v3 - name: Build image run: docker build . multiplatform-image-build: runs-on: ubuntu-22.04 steps: - name: Checkout source code uses: actions/checkout@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build images uses: docker/build-push-action@v3 with: file: Dockerfile platforms: linux/amd64,linux/ppc64le tags: quay.io/eclipse/che-operator:next source-code-validation: runs-on: ubuntu-22.04 steps: - name: Checkout source code uses: actions/checkout@v3 - name: Set up Go 1.19 uses: actions/setup-go@v3 with: go-version: 1.19.13 - name: Cache go modules id: cache-mod uses: actions/cache@v3 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - name: Download dependencies run: go mod download if: steps.cache-mod.outputs.cache-hit != 'true' - name: Check go mod status run: | go mod tidy if [[ ! -z $(git status -s) ]] then echo "Go mod state is not clean:" git --no-pager diff exit 1 fi - name: Check format run: | go install golang.org/x/tools/cmd/goimports@latest go install github.com/che-incubator/check-license-header@379ba18fdb906d341ae451ea155cc34f1c4b4f1a git reset HEAD --hard echo "[INFO] Check code format and imports." make fmt if [[ ! -z $(git status -s) ]] then echo "not well formatted sources are found." echo "execute 'make fmt' to fix the following:" git --no-pager diff exit 1 fi echo "[INFO] Check license headers." FILES_TO_CHECK_LICENSE=$(find . \ -not -path "./mocks/*" \ -not -path "./vendor/*" \ -not -path "./testbin/*" \ -not -path "./bundle/stable/*" \ -not -path "./config/manager/controller_manager_config.yaml" \ \( -name '*.sh' -o -name "*.go" -o -name "*.yaml" -o -name "*.yml" \)) LICENSE_TEMPLATE="${GITHUB_WORKSPACE}/hack/license-header.txt" check-license-header -f "${LICENSE_TEMPLATE}" ${FILES_TO_CHECK_LICENSE} dependencies-md-validation: runs-on: ubuntu-22.04 steps: - name: Checkout source code uses: actions/checkout@v3 - name: Validate DEPENDENCIES.md file uses: che-incubator/dependencies-license-action@0.0.2 env: EXCLUDE_DEPS: "github.com/bmizerany/assert, gotest.tools/v3, github.com/dhui/dktest, gotest.tools, github.com/golangplus/testing"