che-operator/.github/workflows/pr-main-check.yml

101 lines
3.0 KiB
YAML

#
# Copyright (c) 2019-2021 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 validation
on:
pull_request:
branches:
- main
jobs:
resources:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install yq
pip install semver
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
- name: Check resources
run: ${GITHUB_WORKSPACE}/.github/bin/check-resources.sh
bundle-version:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Install yq
run: sudo pip install yq
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
- name: Check OLM bundle version
run: ${GITHUB_WORKSPACE}/.github/bin/check-bundle-version.sh
source-code:
runs-on: ubuntu-20.04
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
- name: Checkout source code
uses: actions/checkout@v1
- name: Cache go modules
id: cache-mod
uses: actions/cache@v2
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 get -u golang.org/x/tools/cmd/goimports
go get -u 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/tech-preview-stable-all-namespaces/*" \
-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}