Skip to content

Commit a3b4603

Browse files
authored
Merge branch '3.0.0' into issue-1173-generators
2 parents 6d29bf4 + b67b9c2 commit a3b4603

File tree

24 files changed

+625
-273
lines changed

24 files changed

+625
-273
lines changed

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "maven"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
ignore:
8+
- dependency-name: "*"
9+
update-types: ["version-update:semver-major"]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: 'Dependency Review'
2+
on: [pull_request]
3+
4+
permissions:
5+
contents: read
6+
7+
jobs:
8+
dependency-review:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: 'Checkout Repository'
12+
uses: actions/checkout@v4
13+
- name: Dependency Review
14+
uses: actions/dependency-review-action@v3
15+
with:
16+
fail-on-severity: high

.github/workflows/docker-release-3.0.yml

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ jobs:
2323
java-version: 17
2424
distribution: temurin
2525
cache: maven
26+
- name: Set up QEMU
27+
uses: docker/setup-qemu-action@v3
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
2630
- name: preliminary checks
2731
run: |
2832
docker login --username=${{ secrets.DOCKERHUB_SB_USERNAME }} --password=${{ secrets.DOCKERHUB_SB_PASSWORD }}
@@ -49,34 +53,51 @@ jobs:
4953
}]
5054
- name: Build with Maven
5155
run: |
52-
# mvn clean install -U -Pdocker -Plinux -DJETTY_TEST_HTTP_PORT=8090 -DJETTY_TEST_STOP_PORT=8089
53-
- name: docker build and push
54-
run: |
55-
export DOCKER_GENERATOR_IMAGE_NAME=swaggerapi/swagger-generator-v3-minimal
56-
export DOCKER_GENERATOR_FULL_IMAGE_NAME=swaggerapi/swagger-generator-v3
57-
export DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME=swaggerapi/swagger-generator-v3-root
58-
export DOCKER_CODEGEN_CLI_IMAGE_NAME=swaggerapi/swagger-codegen-cli-v3
59-
mvn -DJETTY_TEST_HTTP_PORT=8090 -DJETTY_TEST_STOP_PORT=8089 clean install -Pdocker -Prelease --settings $HOME/.m2/settings.xml
60-
docker build --rm=false -t $DOCKER_GENERATOR_IMAGE_NAME:${{ env.TAG }} -f ./modules/swagger-generator/Dockerfile_minimal ./modules/swagger-generator
61-
docker tag $DOCKER_GENERATOR_IMAGE_NAME:${{ env.TAG }} $DOCKER_GENERATOR_IMAGE_NAME:latest
62-
docker push $DOCKER_GENERATOR_IMAGE_NAME:${{ env.TAG }}
63-
docker push $DOCKER_GENERATOR_IMAGE_NAME:latest
64-
docker build --rm=false -t $DOCKER_CODEGEN_CLI_IMAGE_NAME:${{ env.TAG }} ./modules/swagger-codegen-cli
65-
docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:${{ env.TAG }} $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest
66-
docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME:${{ env.TAG }}
67-
docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest
68-
docker push $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}
69-
docker push $DOCKER_GENERATOR_FULL_IMAGE_NAME:latest
70-
echo "docker images:"
71-
docker images | grep -i generator
72-
echo "pushing $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:${{ env.TAG }}"
73-
docker push $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:${{ env.TAG }}
74-
echo "pushing $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:latest"
75-
docker push $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:latest
76-
echo "tagging $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}-root"
77-
docker tag $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:${{ env.TAG }} $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}-root
78-
echo "pushing $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}-root"
79-
docker -D -l debug push $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}-root
56+
mvn clean install -U -Pdocker -DJETTY_TEST_HTTP_PORT=8090 -DJETTY_TEST_STOP_PORT=8089
57+
- name: docker generator build and push
58+
uses: docker/build-push-action@v5
59+
with:
60+
context: ./modules/swagger-generator
61+
file: ./modules/swagger-generator/Dockerfile
62+
push: true
63+
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
64+
provenance: false
65+
build-args: |
66+
HIDDEN_OPTIONS_DEFAULT_PATH=hiddenOptions.yaml
67+
JAVA_MEM=1024m
68+
HTTP_PORT=8080
69+
tags: swaggerapi/swagger-generator-v3:latest,swaggerapi/swagger-generator-v3:${{ env.TAG }}
70+
- name: docker generator root build and push
71+
uses: docker/build-push-action@v5
72+
with:
73+
context: ./modules/swagger-generator
74+
file: ./modules/swagger-generator/Dockerfile_root
75+
push: true
76+
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
77+
provenance: false
78+
build-args: |
79+
HIDDEN_OPTIONS_DEFAULT_PATH=hiddenOptions.yaml
80+
JAVA_MEM=1024m
81+
HTTP_PORT=8080
82+
tags: swaggerapi/swagger-generator-v3-root:latest,swaggerapi/swagger-generator-v3-root:${{ env.TAG }},swaggerapi/swagger-generator-v3:${{ env.TAG }}-root
83+
- name: docker cli build and push
84+
uses: docker/build-push-action@v5
85+
with:
86+
context: ./modules/swagger-generator
87+
file: ./modules/swagger-generator/Dockerfile_minimal
88+
push: true
89+
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
90+
provenance: false
91+
tags: swaggerapi/swagger-codegen-cli-v3:latest,swaggerapi/swagger-codegen-cli-v3:${{ env.TAG }}
92+
- name: docker minimal build and push
93+
uses: docker/build-push-action@v5
94+
with:
95+
context: ./modules/swagger-generator
96+
file: ./modules/swagger-generator/Dockerfile_minimal
97+
push: true
98+
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
99+
provenance: false
100+
tags: swaggerapi/swagger-generator-v3-minimal:latest,swaggerapi/swagger-generator-v3-minimal:${{ env.TAG }}
80101
- name: deploy
81102
run: |
82103
echo "${{ env.TAG }}"
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
name: Build And Push Docker Release Master
2+
3+
on:
4+
workflow_dispatch:
5+
branches: [ "master" ]
6+
inputs:
7+
tag:
8+
description: tag/version to release
9+
required: true
10+
jobs:
11+
build_push_docker_release_master:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
name: git checkout master
18+
with:
19+
ref: master
20+
- name: Set up Java
21+
uses: actions/setup-java@v3
22+
with:
23+
java-version: 17
24+
distribution: temurin
25+
cache: maven
26+
- name: Set up QEMU
27+
uses: docker/setup-qemu-action@v3
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
- name: preliminary checks
31+
run: |
32+
docker login --username=${{ secrets.DOCKERHUB_SB_USERNAME }} --password=${{ secrets.DOCKERHUB_SB_PASSWORD }}
33+
set -e
34+
# fail if templates/generators contain carriage return '\r'
35+
/bin/bash ./bin/utils/detect_carriage_return.sh
36+
# fail if generators contain merge conflicts
37+
/bin/bash ./bin/utils/detect_merge_conflict.sh
38+
# fail if generators contain tab '\t'
39+
/bin/bash ./bin/utils/detect_tab_in_java_class.sh
40+
- uses: s4u/[email protected]
41+
name: setup maven settings.xml
42+
with:
43+
servers: |
44+
[{
45+
"id": "sonatype-nexus-staging",
46+
"username": "${{ secrets.OSSRH_USERNAME }}",
47+
"password": "${{ secrets.OSSRH_TOKEN }}"
48+
},
49+
{
50+
"id": "sonatype-nexus-snapshots",
51+
"username": "${{ secrets.OSSRH_USERNAME }}",
52+
"password": "${{ secrets.OSSRH_TOKEN }}"
53+
}]
54+
- name: Build with Maven
55+
run: |
56+
mvn clean install -U
57+
- name: Build generator image and push
58+
uses: docker/build-push-action@v5
59+
with:
60+
context: ./modules/swagger-generator
61+
push: true
62+
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
63+
provenance: false
64+
tags: swaggerapi/swagger-generator:${{ env.TAG }},swaggerapi/swagger-generator:latest
65+
- name: Build CLI image and push
66+
uses: docker/build-push-action@v5
67+
with:
68+
context: ./modules/swagger-codegen-cli
69+
push: true
70+
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
71+
provenance: false
72+
tags: swaggerapi/swagger-codegen-cli:${{ env.TAG }},swaggerapi/swagger-codegen-cli:latest
73+
- name: deploy
74+
run: |
75+
echo "${{ env.TAG }}"
76+
77+
TOKEN="${{ secrets.RANCHER2_BEARER_TOKEN }}"
78+
RANCHER_HOST="rancher.tools.swagger.io"
79+
CLUSTER_ID="c-n8zp2"
80+
NAMESPACE_NAME="swagger-oss"
81+
K8S_OBJECT_TYPE="daemonsets"
82+
K8S_OBJECT_NAME="swagger-generator"
83+
DEPLOY_IMAGE="swaggerapi/swagger-generator:${{ env.TAG }}"
84+
85+
workloadStatus=""
86+
getStatus() {
87+
echo "Getting update status..."
88+
if ! workloadStatus="$(curl -s -X GET \
89+
-H "Authorization: Bearer ${TOKEN}" \
90+
-H 'Content-Type: application/json' \
91+
"https://${RANCHER_HOST}/k8s/clusters/${CLUSTER_ID}/apis/apps/v1/namespaces/${NAMESPACE_NAME}/${K8S_OBJECT_TYPE}/${K8S_OBJECT_NAME}/status")"
92+
then
93+
echo 'ERROR - get status k8s API call failed!'
94+
echo "Exiting build"...
95+
exit 1
96+
fi
97+
}
98+
99+
# $1 = image to deploy
100+
updateObject() {
101+
local image="${1}"
102+
echo "Updating image value..."
103+
104+
if ! curl -s -X PATCH \
105+
-H "Authorization: Bearer ${TOKEN}" \
106+
-H 'Content-Type: application/json-patch+json' \
107+
"https://${RANCHER_HOST}/k8s/clusters/${CLUSTER_ID}/apis/apps/v1/namespaces/${NAMESPACE_NAME}/${K8S_OBJECT_TYPE}/${K8S_OBJECT_NAME}" \
108+
-d "[{\"op\": \"replace\", \"path\": \"/spec/template/spec/containers/0/image\", \"value\": \"${image}\"}]"
109+
then
110+
echo 'ERROR - image update k8s API call failed!'
111+
echo "Exiting build..."
112+
exit 1
113+
fi
114+
}
115+
116+
117+
# Check that the TAG is valid
118+
if [[ ${{ env.TAG }} =~ ^[vV]?[0-9]*\.[0-9]*\.[0-9]*$ ]]; then
119+
echo ""
120+
echo "This is a Valid TAG..."
121+
122+
# Get current image/tag in case we need to rollback
123+
getStatus
124+
ROLLBACK_IMAGE="$(echo "${workloadStatus}" | jq -r '.spec.template.spec.containers[0].image')"
125+
echo ""
126+
echo "Current image: ${ROLLBACK_IMAGE}"
127+
128+
# Update image and validate response
129+
echo ""
130+
updateObject "${DEPLOY_IMAGE}"
131+
echo ""
132+
133+
echo ""
134+
echo "Waiting for pods to start..."
135+
echo ""
136+
sleep 60s
137+
138+
# Get state of the k8s object. If numberReady == desiredNumberScheduled, consider the upgrade successful. Else raise error
139+
getStatus
140+
status="$(echo "${workloadStatus}" | jq '.status')"
141+
echo ""
142+
echo "${status}"
143+
echo ""
144+
145+
numberDesired="$(echo "${status}" | jq -r '.desiredNumberScheduled')"
146+
numberReady="$(echo "${status}" | jq -r '.numberReady')"
147+
148+
if (( numberReady == numberDesired )); then
149+
echo "${K8S_OBJECT_NAME} has been upgraded to ${DEPLOY_IMAGE}"
150+
151+
# If pods are not starting, rollback the upgrade and exit the build with error
152+
else
153+
echo "state = error...rolling back upgrade"
154+
updateObject "${ROLLBACK_IMAGE}"
155+
echo ""
156+
157+
echo ""
158+
echo "Waiting for rollback pods to start..."
159+
echo ""
160+
sleep 60s
161+
162+
getStatus
163+
status="$(echo "${workloadStatus}" | jq '.status')"
164+
echo ""
165+
echo "${status}"
166+
echo ""
167+
168+
numberDesired="$(echo "${status}" | jq -r '.desiredNumberScheduled')"
169+
numberReady="$(echo "${status}" | jq -r '.numberReady')"
170+
171+
if (( numberReady == numberDesired )); then
172+
echo "Rollback to ${ROLLBACK_IMAGE} completed."
173+
else
174+
echo "FATAL - rollback failed"
175+
fi
176+
echo "Exiting Build..."
177+
exit 1
178+
fi
179+
180+
else
181+
echo "This TAG is not in a valid format..."
182+
echo "Exiting Build..."
183+
exit 0
184+
fi
185+
echo "Exiting Build..."
186+
exit 0
187+
env:
188+
TAG: ${{ github.event.inputs.tag }}

.github/workflows/maven-master-pulls.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,43 @@ jobs:
2727
${{ runner.os }}-maven-
2828
- name: Build with Maven
2929
run: mvn -B -U verify --file pom.xml
30+
31+
build-java8:
32+
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
java: [ 8 ]
37+
38+
steps:
39+
- uses: actions/checkout@v2
40+
- name: Set up Java
41+
uses: actions/setup-java@v1
42+
with:
43+
java-version: ${{ matrix.java }}
44+
- name: Cache local Maven repository
45+
uses: actions/cache@v2
46+
with:
47+
path: ~/.m2/repository
48+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
49+
restore-keys: |
50+
${{ runner.os }}-maven-
51+
- name: Build with Maven
52+
run: mvn -B -U clean verify -DskipTests -Dmaven.test.skip=true -Dmaven.site.skip=true -Dmaven.javadoc.skip=true -Psamples-java8 --file pom.xml
53+
54+
scan-with-lacework:
55+
name: Trigger LaceWork Scanning
56+
runs-on: ubuntu-latest
57+
58+
needs: [ build ]
59+
if: success()
60+
61+
steps:
62+
- name: Trigger LaceWork Scanning using a different method
63+
run: |
64+
docker run -e LW_ACCOUNT_NAME=$LW_ACCOUNT_NAME -e LW_ACCESS_TOKEN=$LW_ACCESS_TOKEN -e LW_SCANNER_SAVE_RESULTS=true -e LW_SCANNER_DISABLE_UPDATES=false -v /var/run/docker.sock:/var/run/docker.sock lacework/lacework-inline-scanner:latest image evaluate swaggerapi/swagger-codegen-cli latest --docker-server index.docker.io --docker-username $docker_user --docker-password $docker_password > /dev/null 2>&1
65+
env:
66+
LW_ACCOUNT_NAME: ${{ secrets.LW_ACCOUNT_NAME }}
67+
LW_ACCESS_TOKEN: ${{ secrets.LW_ACCESS_TOKEN }}
68+
docker_user: ${{ secrets.DOCKERHUB_SB_USERNAME}}
69+
docker_password: ${{ secrets.DOCKERHUB_SB_PASSWORD}}

0 commit comments

Comments
 (0)