Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix workflows JDK #12114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 121 additions & 1 deletion .github/workflows/docker-release-3.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,129 @@ jobs:
docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest
docker push $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}
docker push $DOCKER_GENERATOR_FULL_IMAGE_NAME:latest
echo "docker images:"
docker images | grep -i generator
echo "pushing $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:${{ env.TAG }}"
docker push $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:${{ env.TAG }}
echo "pushing $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:latest"
docker push $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:latest
echo "tagging $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}-root"
docker tag $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:${{ env.TAG }} $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}-root
docker push $DOCKER_GENERATOR_FULL_IMAGE_NAME:$${{ env.TAG }}-root
echo "pushing $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}-root"
docker -D -l debug push $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}-root
- name: deploy
run: |
echo "${{ env.TAG }}"

TOKEN="${{ secrets.RANCHER2_BEARER_TOKEN }}"
RANCHER_HOST="rancher.tools.swagger.io"
CLUSTER_ID="c-n8zp2"
NAMESPACE_NAME="swagger-oss"
K8S_OBJECT_TYPE="daemonsets"
K8S_OBJECT_NAME="swagger-generator-v3"
DEPLOY_IMAGE="swaggerapi/swagger-generator-v3:${{ env.TAG }}"

workloadStatus=""
getStatus() {
echo "Getting update status..."
if ! workloadStatus="$(curl -s -X GET \
-H "Authorization: Bearer ${TOKEN}" \
-H 'Content-Type: application/json' \
"https://${RANCHER_HOST}/k8s/clusters/${CLUSTER_ID}/apis/apps/v1/namespaces/${NAMESPACE_NAME}/${K8S_OBJECT_TYPE}/${K8S_OBJECT_NAME}/status")"
then
echo 'ERROR - get status k8s API call failed!'
echo "Exiting build"...
exit 1
fi
}

# $1 = image to deploy
updateObject() {
local image="${1}"
echo "Updating image value..."

if ! curl -s -X PATCH \
-H "Authorization: Bearer ${TOKEN}" \
-H 'Content-Type: application/json-patch+json' \
"https://${RANCHER_HOST}/k8s/clusters/${CLUSTER_ID}/apis/apps/v1/namespaces/${NAMESPACE_NAME}/${K8S_OBJECT_TYPE}/${K8S_OBJECT_NAME}" \
-d "[{\"op\": \"replace\", \"path\": \"/spec/template/spec/containers/0/image\", \"value\": \"${image}\"}]"
then
echo 'ERROR - image update k8s API call failed!'
echo "Exiting build..."
exit 1
fi
}


# Check that the TAG is valid
if [[ ${{ env.TAG }} =~ ^[vV]?[0-9]*\.[0-9]*\.[0-9]*$ ]]; then
echo ""
echo "This is a Valid TAG..."

# Get current image/tag in case we need to rollback
getStatus
ROLLBACK_IMAGE="$(echo "${workloadStatus}" | jq -r '.spec.template.spec.containers[0].image')"
echo ""
echo "Current image: ${ROLLBACK_IMAGE}"

# Update image and validate response
echo ""
updateObject "${DEPLOY_IMAGE}"
echo ""

echo ""
echo "Waiting for pods to start..."
echo ""
sleep 60s

# Get state of the k8s object. If numberReady == desiredNumberScheduled, consider the upgrade successful. Else raise error
getStatus
status="$(echo "${workloadStatus}" | jq '.status')"
echo ""
echo "${status}"
echo ""

numberDesired="$(echo "${status}" | jq -r '.desiredNumberScheduled')"
numberReady="$(echo "${status}" | jq -r '.numberReady')"

if (( numberReady == numberDesired )); then
echo "${K8S_OBJECT_NAME} has been upgraded to ${DEPLOY_IMAGE}"

# If pods are not starting, rollback the upgrade and exit the build with error
else
echo "state = error...rolling back upgrade"
updateObject "${ROLLBACK_IMAGE}"
echo ""

echo ""
echo "Waiting for rollback pods to start..."
echo ""
sleep 60s

getStatus
status="$(echo "${workloadStatus}" | jq '.status')"
echo ""
echo "${status}"
echo ""

numberDesired="$(echo "${status}" | jq -r '.desiredNumberScheduled')"
numberReady="$(echo "${status}" | jq -r '.numberReady')"

if (( numberReady == numberDesired )); then
echo "Rollback to ${ROLLBACK_IMAGE} completed."
else
echo "FATAL - rollback failed"
fi
echo "Exiting Build..."
exit 1
fi

else
echo "This TAG is not in a valid format..."
echo "Exiting Build..."
exit 0
fi
echo "Exiting Build..."
exit 0
env:
TAG: ${{ github.event.inputs.tag }}
116 changes: 116 additions & 0 deletions .github/workflows/maven-pr-3.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Build Test PR 3.0

on:
pull_request:
branches: [ "3.0.0" ]

jobs:
build_pr_30:

runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11, 17 ]

env:
GENERATORS_VERSION_PROPERTY: ""
steps:
- uses: actions/checkout@v3
name: git checkout 3.0.0
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
cache: maven
- name: preliminary checks
run: |
docker login --username=${{ secrets.DOCKERHUB_SB_USERNAME }} --password=${{ secrets.DOCKERHUB_SB_PASSWORD }}
set -e
# fail if templates/generators contain carriage return '\r'
/bin/bash ./bin/utils/detect_carriage_return.sh
# fail if generators contain merge conflicts
/bin/bash ./bin/utils/detect_merge_conflict.sh
# fail if generators contain tab '\t'
/bin/bash ./bin/utils/detect_tab_in_java_class.sh
- uses: s4u/[email protected]
name: setup maven settings.xml
with:
servers: |
[{
"id": "sonatype-nexus-staging",
"username": "${{ secrets.OSSRH_USERNAME }}",
"password": "${{ secrets.OSSRH_TOKEN }}"
},
{
"id": "sonatype-nexus-snapshots",
"username": "${{ secrets.OSSRH_USERNAME }}",
"password": "${{ secrets.OSSRH_TOKEN }}"
}]
- name: Build with Maven
if: ${{ matrix.java != 8 }}
run: |
export MY_POM_VERSION=`mvn -Dswagger-codegen-generators-version=1.0.37 -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
export GENERATORS_VERSION=`sed -n 's/<swagger\-codegen\-generators\-version>\([^\s]*\)<\/swagger\-codegen\-generators\-version>/\1/p' pom.xml`
export GENERATORS_VERSION=`echo ${GENERATORS_VERSION} | tr -d '[:space:]'`
echo "GENERATORS_VERSION" ${GENERATORS_VERSION}
export GENERATORS_VERSION_PROPERTY=""
if [[ ! $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
then
if [[ ! $GENERATORS_VERSION =~ ^.*SNAPSHOT$ ]];
then
# check release version exists
export GENERATORS_FOUND_JSON=`curl -s --max-time 60 --retry 15 --connect-timeout 20 https://search.maven.org/solrsearch/select?q=g:io.swagger.codegen.v3%20AND%20a:swagger-codegen-generators%20AND%20v:${GENERATORS_VERSION}%20AND%20p:jar`
export GENERATORS_FOUND=`echo ${GENERATORS_FOUND_JSON} | jq '.response.numFound'`
echo "GENERATORS_FOUND" ${GENERATORS_FOUND}
if [[ $GENERATORS_FOUND == '0' ]];
then
echo "generators version not found"
rm -f maven-metadata.json
curl -o maven-metadata.json -s --max-time 60 --retry 15 --connect-timeout 30 -H "accept: application/json" https://oss.sonatype.org/service/local/repositories/snapshots/content/io/swagger/codegen/v3/swagger-codegen-generators/
LAST_SNAP=`jq '.data | sort_by(.lastModified) | reverse | .[0].text' maven-metadata.json`
export LAST_SNAP=${LAST_SNAP:1:${#LAST_SNAP}-2}
echo "LAST_SNAP $LAST_SNAP"
export GENERATORS_VERSION_PROPERTY=-Dswagger-codegen-generators-version=$LAST_SNAP
fi
fi
fi
echo "GENERATORS_VERSION_PROPERTY ${GENERATORS_VERSION_PROPERTY}"
echo "GENERATORS_VERSION_PROPERTY=${GENERATORS_VERSION_PROPERTY}" >> $GITHUB_ENV
mvn clean verify -U -DJETTY_TEST_HTTP_PORT=8070 -DJETTY_TEST_STOP_PORT=8069 ${GENERATORS_VERSION_PROPERTY}
- name: Build and test samples Java 8
if: ${{ matrix.java == 8 }}
run: |
export MY_POM_VERSION=`mvn -Dswagger-codegen-generators-version=1.0.37 -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
export GENERATORS_VERSION=`sed -n 's/<swagger\-codegen\-generators\-version>\([^\s]*\)<\/swagger\-codegen\-generators\-version>/\1/p' pom.xml`
export GENERATORS_VERSION=`echo ${GENERATORS_VERSION} | tr -d '[:space:]'`
echo "GENERATORS_VERSION" ${GENERATORS_VERSION}
export GENERATORS_VERSION_PROPERTY=""
if [[ ! $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
then
if [[ ! $GENERATORS_VERSION =~ ^.*SNAPSHOT$ ]];
then
# check release version exists
export GENERATORS_FOUND_JSON=`curl -s --max-time 60 --retry 15 --connect-timeout 20 https://search.maven.org/solrsearch/select?q=g:io.swagger.codegen.v3%20AND%20a:swagger-codegen-generators%20AND%20v:${GENERATORS_VERSION}%20AND%20p:jar`
export GENERATORS_FOUND=`echo ${GENERATORS_FOUND_JSON} | jq '.response.numFound'`
echo "GENERATORS_FOUND" ${GENERATORS_FOUND}
if [[ $GENERATORS_FOUND == '0' ]];
then
echo "generators version not found"
rm -f maven-metadata.json
curl -o maven-metadata.json -s --max-time 60 --retry 15 --connect-timeout 30 -H "accept: application/json" https://oss.sonatype.org/service/local/repositories/snapshots/content/io/swagger/codegen/v3/swagger-codegen-generators/
LAST_SNAP=`jq '.data | sort_by(.lastModified) | reverse | .[0].text' maven-metadata.json`
export LAST_SNAP=${LAST_SNAP:1:${#LAST_SNAP}-2}
echo "LAST_SNAP $LAST_SNAP"
export GENERATORS_VERSION_PROPERTY=-Dswagger-codegen-generators-version=$LAST_SNAP
fi
fi
fi
echo "GENERATORS_VERSION_PROPERTY ${GENERATORS_VERSION_PROPERTY}"
echo "GENERATORS_VERSION_PROPERTY=${GENERATORS_VERSION_PROPERTY}" >> $GITHUB_ENV
cp -a pom.java8.xml pom.xml
echo "Test samples - GENERATORS_VERSION_PROPERTY ${{ env.GENERATORS_VERSION_PROPERTY }}"
mvn -q verify -U -Psamples -DskipTests -Dmaven.test.skip=true -Dmaven.site.skip=true -Dmaven.javadoc.skip=true -Dproject.build.sourceEncoding=UTF8 -Dfile.encoding=UTF8 ${{ env.GENERATORS_VERSION_PROPERTY }}
cp -a pom.java11.xml pom.xml
138 changes: 138 additions & 0 deletions .github/workflows/maven-push-3.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Build Test Push 3.0

on:
push:
branches: [ "3.0.0" ]

jobs:
build_push_30:

runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11, 17 ]

env:
GENERATORS_VERSION_PROPERTY: ""

steps:
- uses: actions/checkout@v3
name: git checkout 3.0.0
with:
ref: 3.0.0
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
cache: maven
- name: preliminary checks
run: |
docker login --username=${{ secrets.DOCKERHUB_SB_USERNAME }} --password=${{ secrets.DOCKERHUB_SB_PASSWORD }}
set -e
# fail if templates/generators contain carriage return '\r'
/bin/bash ./bin/utils/detect_carriage_return.sh
# fail if generators contain merge conflicts
/bin/bash ./bin/utils/detect_merge_conflict.sh
# fail if generators contain tab '\t'
/bin/bash ./bin/utils/detect_tab_in_java_class.sh
- uses: s4u/[email protected]
name: setup maven settings.xml
with:
servers: |
[{
"id": "sonatype-nexus-staging",
"username": "${{ secrets.OSSRH_USERNAME }}",
"password": "${{ secrets.OSSRH_TOKEN }}"
},
{
"id": "sonatype-nexus-snapshots",
"username": "${{ secrets.OSSRH_USERNAME }}",
"password": "${{ secrets.OSSRH_TOKEN }}"
}]
- name: Build with Maven
if: ${{ matrix.java != 8 }}
run: |
export MY_POM_VERSION=`mvn -Dswagger-codegen-generators-version=1.0.37 -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
export GENERATORS_VERSION=`sed -n 's/<swagger\-codegen\-generators\-version>\([^\s]*\)<\/swagger\-codegen\-generators\-version>/\1/p' pom.xml`
export GENERATORS_VERSION=`echo ${GENERATORS_VERSION} | tr -d '[:space:]'`
echo "GENERATORS_VERSION" ${GENERATORS_VERSION}
export GENERATORS_VERSION_PROPERTY=""
if [[ ! $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
then
if [[ ! $GENERATORS_VERSION =~ ^.*SNAPSHOT$ ]];
then
# check release version exists
export GENERATORS_FOUND_JSON=`curl -s --max-time 60 --retry 15 --connect-timeout 20 https://search.maven.org/solrsearch/select?q=g:io.swagger.codegen.v3%20AND%20a:swagger-codegen-generators%20AND%20v:${GENERATORS_VERSION}%20AND%20p:jar`
export GENERATORS_FOUND=`echo ${GENERATORS_FOUND_JSON} | jq '.response.numFound'`
echo "GENERATORS_FOUND" ${GENERATORS_FOUND}
if [[ $GENERATORS_FOUND == '0' ]];
then
echo "generators version not found"
rm -f maven-metadata.json
curl -o maven-metadata.json -s --max-time 60 --retry 15 --connect-timeout 30 -H "accept: application/json" https://oss.sonatype.org/service/local/repositories/snapshots/content/io/swagger/codegen/v3/swagger-codegen-generators/
LAST_SNAP=`jq '.data | sort_by(.lastModified) | reverse | .[0].text' maven-metadata.json`
export LAST_SNAP=${LAST_SNAP:1:${#LAST_SNAP}-2}
echo "LAST_SNAP $LAST_SNAP"
export GENERATORS_VERSION_PROPERTY=-Dswagger-codegen-generators-version=$LAST_SNAP
fi
fi
fi
echo "GENERATORS_VERSION_PROPERTY ${GENERATORS_VERSION_PROPERTY}"
echo "GENERATORS_VERSION_PROPERTY=${GENERATORS_VERSION_PROPERTY}" >> $GITHUB_ENV
mvn clean verify -U -DJETTY_TEST_HTTP_PORT=8070 -DJETTY_TEST_STOP_PORT=8069 ${GENERATORS_VERSION_PROPERTY}
mvn clean install -U -Pdocker -Plinux -DJETTY_TEST_HTTP_PORT=8090 -DJETTY_TEST_STOP_PORT=8089 ${GENERATORS_VERSION_PROPERTY}
- name: Build and test samples Java 8
if: ${{ matrix.java == 8 }}
run: |
export MY_POM_VERSION=`mvn -Dswagger-codegen-generators-version=1.0.37 -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
export GENERATORS_VERSION=`sed -n 's/<swagger\-codegen\-generators\-version>\([^\s]*\)<\/swagger\-codegen\-generators\-version>/\1/p' pom.xml`
export GENERATORS_VERSION=`echo ${GENERATORS_VERSION} | tr -d '[:space:]'`
echo "GENERATORS_VERSION" ${GENERATORS_VERSION}
export GENERATORS_VERSION_PROPERTY=""
if [[ ! $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
then
if [[ ! $GENERATORS_VERSION =~ ^.*SNAPSHOT$ ]];
then
# check release version exists
export GENERATORS_FOUND_JSON=`curl -s --max-time 60 --retry 15 --connect-timeout 20 https://search.maven.org/solrsearch/select?q=g:io.swagger.codegen.v3%20AND%20a:swagger-codegen-generators%20AND%20v:${GENERATORS_VERSION}%20AND%20p:jar`
export GENERATORS_FOUND=`echo ${GENERATORS_FOUND_JSON} | jq '.response.numFound'`
echo "GENERATORS_FOUND" ${GENERATORS_FOUND}
if [[ $GENERATORS_FOUND == '0' ]];
then
echo "generators version not found"
rm -f maven-metadata.json
curl -o maven-metadata.json -s --max-time 60 --retry 15 --connect-timeout 30 -H "accept: application/json" https://oss.sonatype.org/service/local/repositories/snapshots/content/io/swagger/codegen/v3/swagger-codegen-generators/
LAST_SNAP=`jq '.data | sort_by(.lastModified) | reverse | .[0].text' maven-metadata.json`
export LAST_SNAP=${LAST_SNAP:1:${#LAST_SNAP}-2}
echo "LAST_SNAP $LAST_SNAP"
export GENERATORS_VERSION_PROPERTY=-Dswagger-codegen-generators-version=$LAST_SNAP
fi
fi
fi
echo "GENERATORS_VERSION_PROPERTY ${GENERATORS_VERSION_PROPERTY}"
echo "GENERATORS_VERSION_PROPERTY=${GENERATORS_VERSION_PROPERTY}" >> $GITHUB_ENV
cp -a pom.java8.xml pom.xml
echo "Test samples - GENERATORS_VERSION_PROPERTY ${{ env.GENERATORS_VERSION_PROPERTY }}"
mvn -q verify -U -Psamples -DskipTests -Dmaven.test.skip=true -Dmaven.site.skip=true -Dmaven.javadoc.skip=true -Dproject.build.sourceEncoding=UTF8 -Dfile.encoding=UTF8 ${{ env.GENERATORS_VERSION_PROPERTY }}
cp -a pom.java11.xml pom.xml
- name: docker cli and minimal build and push
if: ${{ matrix.java == 17 }}
run: |
export MY_POM_VERSION=`mvn -Dswagger-codegen-generators-version=1.0.37 -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
export DOCKER_GENERATOR_IMAGE_NAME=swaggerapi/swagger-generator-v3-minimal
export DOCKER_CODEGEN_CLI_IMAGE_NAME=swaggerapi/swagger-codegen-cli-v3
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
then
mvn -DJETTY_TEST_HTTP_PORT=8090 -DJETTY_TEST_STOP_PORT=8089 clean deploy -Pdocker --settings $HOME/.m2/settings.xml
docker build --rm=false -t $DOCKER_GENERATOR_IMAGE_NAME:unstable -f ./modules/swagger-generator/Dockerfile_minimal ./modules/swagger-generator
docker push $DOCKER_GENERATOR_IMAGE_NAME:unstable
docker build --rm=false -t $DOCKER_CODEGEN_CLI_IMAGE_NAME:unstable ./modules/swagger-codegen-cli
docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME:unstable
else
echo "not building and pushing release docker image: " ${MY_POM_VERSION}
fi

2 changes: 1 addition & 1 deletion .github/workflows/test-framework-clojure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

strategy:
matrix:
java: [ 8 ]
java: [ 11 ]

steps:
- uses: actions/checkout@v2
Expand Down
Loading