Skip to content

Commit

Permalink
Merge pull request #351 from netgroup-polito/mio/test-generated
Browse files Browse the repository at this point in the history
  • Loading branch information
kingmakerbot authored Nov 25, 2020
2 parents a24ba93 + c9120c1 commit e41069f
Show file tree
Hide file tree
Showing 8 changed files with 1,003 additions and 380 deletions.
70 changes: 66 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Code testing
on:
pull_request:
pull_request_target:
types:
- opened
- reopened
- synchronize

jobs:
laboratory-operator:
name: Laboratory Operator
operators:
name: Operators
runs-on: ubuntu-latest

steps:
Expand All @@ -29,13 +29,75 @@ jobs:
curl -L -O "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${version}/kubebuilder_${version}_linux_${arch}.tar.gz"
tar -zxvf kubebuilder_${version}_linux_${arch}.tar.gz
mv kubebuilder_${version}_linux_${arch} kubebuilder && sudo mv kubebuilder /usr/local/
- name: Perform the tests
working-directory: operators/
run: |
make test
operators-generated:
name: Operators (Generated manifests)
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: 1.15

- name: Run the automatic generation
working-directory: operators/
run: |
make generate
make manifests
- name: Gather the differences
id: git-diff
run: |
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 "::set-output name=diff::${output}"
# Trigger a failure in case the diff is not empty
exit ${exit_code}
- name: Issue a comment in case the diff is not empty
uses: peter-evans/create-or-update-comment@v1
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: failure()


kubernetes-manifests:
name: Kubernetes manifests
runs-on: ubuntu-latest
Expand Down
6 changes: 1 addition & 5 deletions operators/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand All @@ -25,7 +21,7 @@ uninstall: manifests
# Generate manifests e.g. CRD, RBAC etc.

manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./api/..." output:crd:artifacts:config=deploy/crds
$(CONTROLLER_GEN) crd:maxDescLen=127 paths="./api/..." output:crd:artifacts:config=deploy/crds
# Run go fmt against code
fmt:
go fmt ./...
Expand Down
10 changes: 4 additions & 6 deletions operators/deploy/crds/crownlabs.polito.it_imagelists.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ spec:
description: ImageList is the Schema for the ImageList API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: APIVersion defines the versioned schema of this representation
of an object.
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: Kind is a string value representing the REST resource this
object represents.
type: string
metadata:
type: object
Expand Down
6 changes: 4 additions & 2 deletions operators/deploy/crds/crownlabs.polito.it_labinstances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ spec:
description: LabInstance is the Schema for the labinstances API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: APIVersion defines the versioned schema of this representation
of an object.
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: Kind is a string value representing the REST resource this
object represents.
type: string
metadata:
type: object
Expand Down
Loading

0 comments on commit e41069f

Please sign in to comment.