AutoEnroll feature on frontend #5205
Workflow file for this run
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: Code testing | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- "v*" | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
jobs: | |
configure: | |
name: Preliminary configuration | |
runs-on: ubuntu-latest | |
outputs: | |
ref: ${{ steps.configure.outputs.ref }} | |
repo-name: ${{ steps.configure.outputs.repo-name }} | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- name: Get version | |
id: version | |
run: echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT | |
if: | | |
github.event_name == 'push' && | |
github.event.repository.full_name == github.repository && | |
startsWith(github.ref, 'refs/tags/v') | |
- name: Configure | |
id: configure | |
run: | | |
# The ref of the commit to checkout (do not use the merge commit if pull request) | |
if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then | |
echo "ref=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT | |
echo "repo-name=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_OUTPUT | |
elif [[ "${{ steps.version.outputs.version }}" != "" ]]; then | |
echo "ref=${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT | |
echo "repo-name=${{ github.repository }}" >> $GITHUB_OUTPUT | |
else | |
echo "ref=${{ github.sha }}" >> $GITHUB_OUTPUT | |
echo "repo-name=${{ github.repository }}" >> $GITHUB_OUTPUT | |
fi | |
operators: | |
name: Operators | |
runs-on: ubuntu-latest | |
needs: configure | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: "${{ needs.configure.outputs.ref }}" | |
repository: "${{ needs.configure.outputs.repo-name }}" | |
persist-credentials: false | |
- name: Check if /operators files changed | |
uses: dorny/paths-filter@v2 | |
id: pathFilter | |
with: | |
filters: | | |
operators: | |
- 'operators/**' | |
- name: Setup Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install Kubebuilder | |
run: | | |
version=2.3.1 # latest stable version | |
kubernetes_version=1.25.0 | |
curl -L -O "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${version}/kubebuilder_${version}_linux_$(go env GOARCH).tar.gz" | |
tar -zxvf kubebuilder_${version}_linux_$(go env GOARCH).tar.gz | |
mv kubebuilder_${version}_linux_$(go env GOARCH) kubebuilder | |
curl --fail -sSLo envtest-bins.tar.gz "https://go.kubebuilder.io/test-tools/${kubernetes_version}/$(go env GOOS)/$(go env GOARCH)" | |
tar -zxvf envtest-bins.tar.gz kubebuilder/bin/kube-apiserver --overwrite -C kubebuilder/bin | |
sudo mv kubebuilder /usr/local/ | |
- name: Perform the tests | |
working-directory: operators/ | |
run: | | |
make test | |
make test-python | |
- name: Send coverage | |
if: steps.pathFilter.outputs.operators == 'true' | |
uses: shogo82148/actions-goveralls@v1 | |
with: | |
path-to-profile: coverage.out | |
working-directory: operators/ | |
operators-generated: | |
name: Operators (Generated manifests) | |
runs-on: ubuntu-latest | |
needs: configure | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: "${{ needs.configure.outputs.ref }}" | |
repository: "${{ needs.configure.outputs.repo-name }}" | |
persist-credentials: false | |
- name: Setup Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19 | |
- name: Run the automatic generation | |
working-directory: operators/ | |
run: | | |
make generate | |
make manifests | |
- name: Gather the differences | |
id: git-diff | |
run: | | |
# Ensure new files are also considered in the diff | |
git add --intent-to-add . | |
output=$(git diff | head -n 100) | |
exit_code=$([ "${output}" ] && echo 1 || echo 0) | |
# Required to correctly manage multi-line outputs | |
output="${output//'%'/'%25'}" | |
output="${output//$'\n'/'%0A'}" | |
output="${output//$'\r'/'%0D'}" | |
echo "diff=${output}" >> $GITHUB_OUTPUT | |
# Trigger a failure in case the diff is not empty | |
exit ${exit_code} | |
- name: Log the error if the diff is not empty (in case the comment cannot be generated) | |
run: | | |
echo "The generated artifacts appear to be out-of-date." | |
echo | |
echo "Here it is an excerpt of the diff:" | |
echo "${{ steps.git-diff.outputs.diff }}" | |
if: failure() | |
- name: Issue a comment in case the diff is not empty | |
uses: peter-evans/create-or-update-comment@v2 | |
with: | |
token: ${{ secrets.CI_TOKEN }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
The generated files in the `operators/` folder appear to be out-of-date. | |
Please, ensure you are using the correct version of `controller-gen` and re-run: | |
``` | |
make generate | |
make manifests | |
``` | |
<details> | |
<summary>Here it is an excerpt of the diff:</summary> | |
```diff | |
${{ steps.git-diff.outputs.diff }} | |
``` | |
</details> | |
reactions: confused | |
if: | | |
github.event_name != 'push' && failure() && | |
github.event.pull_request.head.repo.full_name == github.repository | |
kubernetes-manifests: | |
name: Kubernetes manifests | |
runs-on: ubuntu-latest | |
needs: configure | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: "${{ needs.configure.outputs.ref }}" | |
repository: "${{ needs.configure.outputs.repo-name }}" | |
persist-credentials: false | |
- name: Update the Helm chart dependencies | |
uses: WyriHaximus/github-action-helm3@v2 | |
with: | |
exec: | |
helm dependency update ./deploy/crownlabs | |
- name: Verify that the helm chart is well-formed | |
uses: WyriHaximus/github-action-helm3@v2 | |
with: | |
exec: | |
helm lint ./deploy/crownlabs --with-subcharts | |
- name: Render the yaml manifests | |
id: helm-template | |
uses: WyriHaximus/github-action-helm3@v2 | |
with: | |
exec: | |
helm template crownlabs ./deploy/crownlabs | |
--namespace crownlabs-production | |
--set global.version=v0.0.1 | |
- name: Save the rendered manifests | |
run: | | |
echo '${{ steps.helm-template.outputs.helm_output }}' > ./deploy/crownlabs/rendered.yaml | |
- name: KubeScore Check | |
run: | | |
docker run -v ${{ github.workspace }}:/CrownLabs zegl/kube-score:v1.11.0 score \ | |
--ignore-test=pod-networkpolicy,container-security-context,container-image-pull-policy \ | |
/CrownLabs/deploy/crownlabs/rendered.yaml |