Skip to content

Commit 71e5cf7

Browse files
authored
Merge branch 'master' into typescript-node-date-format
2 parents 6a81439 + 949f0e6 commit 71e5cf7

File tree

1,034 files changed

+175069
-9947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,034 files changed

+175069
-9947
lines changed

.github/actions/build/action.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ runs:
2424
name: build
2525
run: |
2626
buildlogfile=${{ inputs.job-name }}-build.log
27-
echo "::set-output name=path::$(echo generated/${{ inputs.job-name }})"
27+
echo "path=$(echo generated/${{ inputs.job-name }})" >> $GITHUB_OUTPUT
2828
curdir=$(pwd)
2929
echo -e "\n****** BUILD ******\n" >> $curdir/$buildlogfile
3030
cd ${{ inputs.path }}
3131
echo -e "${{ inputs.build-commands }}" > $curdir/buildcommands.log
32-
echo "::set-output name=logs::$(echo $curdir/$buildlogfile)"
32+
echo "logs=$(echo $curdir/$buildlogfile)" >> $GITHUB_OUTPUT
3333
buildcommands=$(cat $curdir/buildcommands.log)
3434
3535
while [ "$buildcommands" ] ;do
@@ -41,6 +41,8 @@ runs:
4141
buildcommands='' || \
4242
buildcommands="${buildcommands#*__&&__}"
4343
done
44+
echo -e "\n****** executed all buildcommands ******\n"
45+
echo -e "\n****** executed all buildcommand ******\n" >> $curdir/$buildlogfile
4446
cd ${curdir}
45-
echo "::set-output name=logs::$(echo $curdir/$buildlogfile)"
47+
echo "logs=$(echo $curdir/$buildlogfile)" >> $GITHUB_OUTPUT
4648
shell: bash

.github/actions/generate/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ runs:
3232
chmod +x ${{ github.action_path }}/generate.sh
3333
echo "${{ inputs.language }} ${{ inputs.job-name }} ${{ inputs.spec-url }} ${{ inputs.options }}"
3434
echo -e "\n****** generate ******\n" > $logfile
35-
echo "::set-output name=logs::$(echo $logfile)"
35+
echo "logs=$(echo $logfile)" >> $GITHUB_OUTPUT
3636
${{ github.action_path }}/generate.sh ${{ inputs.language }} ${{ inputs.job-name }} ${{ inputs.spec-url }} ${{ inputs.options }} 2>&1 | tee --append $logfile
37-
echo "::set-output name=path::$(echo generated/${{ inputs.job-name }})"
38-
echo "::set-output name=logs::$(echo $logfile)"
37+
echo "path=$(echo generated/${{ inputs.job-name }})" >> $GITHUB_OUTPUT
38+
echo "logs=$(echo $logfile)" >> $GITHUB_OUTPUT
3939
shell: bash

.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"]

.github/workflows/codeql.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
schedule:
16+
- cron: '16 04 * * 2'
17+
18+
jobs:
19+
analyze:
20+
name: Analyze (${{ matrix.language }})
21+
# Runner size impacts CodeQL analysis time. To learn more, please see:
22+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
23+
# - https://gh.io/supported-runners-and-hardware-resources
24+
# - https://gh.io/using-larger-runners (GitHub.com only)
25+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
26+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
27+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
28+
permissions:
29+
# required for all workflows
30+
security-events: write
31+
32+
# required to fetch internal or private CodeQL packs
33+
packages: read
34+
35+
# only required for workflows in private repositories
36+
actions: read
37+
contents: read
38+
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
language: [ 'java' ]
43+
44+
steps:
45+
- name: Checkout repository
46+
uses: actions/checkout@v4
47+
48+
# Initializes the CodeQL tools for scanning.
49+
- name: Initialize CodeQL
50+
uses: github/codeql-action/init@v3
51+
with:
52+
languages: ${{ matrix.language }}
53+
54+
- name: Autobuild
55+
uses: github/codeql-action/autobuild@v3
56+
57+
- name: Perform CodeQL Analysis
58+
uses: github/codeql-action/analyze@v3
59+
with:
60+
category: "/language:${{matrix.language}}"
61+
output: sarif-results
62+
upload: failure-only
63+
64+
- name: filter-sarif
65+
uses: advanced-security/filter-sarif@v1
66+
with:
67+
patterns: |
68+
-**/samples/**
69+
input: sarif-results/java.sarif
70+
output: sarif-results/java.sarif
71+
72+
- name: Upload SARIF
73+
uses: github/codeql-action/upload-sarif@v3
74+
with:
75+
sarif_file: sarif-results/java.sarif
76+
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
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
name: Build And Push Docker Release 3.0
2+
3+
on:
4+
workflow_dispatch:
5+
branches: [ "3.0.0" ]
6+
inputs:
7+
tag:
8+
description: tag/version to release
9+
required: true
10+
jobs:
11+
build_push_docker_release_30:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
name: git checkout 3.0.0
18+
with:
19+
ref: 3.0.0
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: preliminary checks
27+
run: |
28+
docker login --username=${{ secrets.DOCKERHUB_SB_USERNAME }} --password=${{ secrets.DOCKERHUB_SB_PASSWORD }}
29+
set -e
30+
# fail if templates/generators contain carriage return '\r'
31+
/bin/bash ./bin/utils/detect_carriage_return.sh
32+
# fail if generators contain merge conflicts
33+
/bin/bash ./bin/utils/detect_merge_conflict.sh
34+
# fail if generators contain tab '\t'
35+
/bin/bash ./bin/utils/detect_tab_in_java_class.sh
36+
- uses: s4u/maven-settings-action@v2.8.0
37+
name: setup maven settings.xml
38+
with:
39+
servers: |
40+
[{
41+
"id": "sonatype-nexus-staging",
42+
"username": "${{ secrets.OSSRH_USERNAME }}",
43+
"password": "${{ secrets.OSSRH_TOKEN }}"
44+
},
45+
{
46+
"id": "sonatype-nexus-snapshots",
47+
"username": "${{ secrets.OSSRH_USERNAME }}",
48+
"password": "${{ secrets.OSSRH_TOKEN }}"
49+
}]
50+
- name: Build with Maven
51+
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
80+
- name: deploy
81+
run: |
82+
echo "${{ env.TAG }}"
83+
84+
TOKEN="${{ secrets.RANCHER2_BEARER_TOKEN }}"
85+
RANCHER_HOST="rancher.tools.swagger.io"
86+
CLUSTER_ID="c-n8zp2"
87+
NAMESPACE_NAME="swagger-oss"
88+
K8S_OBJECT_TYPE="daemonsets"
89+
K8S_OBJECT_NAME="swagger-generator-v3"
90+
DEPLOY_IMAGE="swaggerapi/swagger-generator-v3:${{ env.TAG }}"
91+
92+
workloadStatus=""
93+
getStatus() {
94+
echo "Getting update status..."
95+
if ! workloadStatus="$(curl -s -X GET \
96+
-H "Authorization: Bearer ${TOKEN}" \
97+
-H 'Content-Type: application/json' \
98+
"https://${RANCHER_HOST}/k8s/clusters/${CLUSTER_ID}/apis/apps/v1/namespaces/${NAMESPACE_NAME}/${K8S_OBJECT_TYPE}/${K8S_OBJECT_NAME}/status")"
99+
then
100+
echo 'ERROR - get status k8s API call failed!'
101+
echo "Exiting build"...
102+
exit 1
103+
fi
104+
}
105+
106+
# $1 = image to deploy
107+
updateObject() {
108+
local image="${1}"
109+
echo "Updating image value..."
110+
111+
if ! curl -s -X PATCH \
112+
-H "Authorization: Bearer ${TOKEN}" \
113+
-H 'Content-Type: application/json-patch+json' \
114+
"https://${RANCHER_HOST}/k8s/clusters/${CLUSTER_ID}/apis/apps/v1/namespaces/${NAMESPACE_NAME}/${K8S_OBJECT_TYPE}/${K8S_OBJECT_NAME}" \
115+
-d "[{\"op\": \"replace\", \"path\": \"/spec/template/spec/containers/0/image\", \"value\": \"${image}\"}]"
116+
then
117+
echo 'ERROR - image update k8s API call failed!'
118+
echo "Exiting build..."
119+
exit 1
120+
fi
121+
}
122+
123+
124+
# Check that the TAG is valid
125+
if [[ ${{ env.TAG }} =~ ^[vV]?[0-9]*\.[0-9]*\.[0-9]*$ ]]; then
126+
echo ""
127+
echo "This is a Valid TAG..."
128+
129+
# Get current image/tag in case we need to rollback
130+
getStatus
131+
ROLLBACK_IMAGE="$(echo "${workloadStatus}" | jq -r '.spec.template.spec.containers[0].image')"
132+
echo ""
133+
echo "Current image: ${ROLLBACK_IMAGE}"
134+
135+
# Update image and validate response
136+
echo ""
137+
updateObject "${DEPLOY_IMAGE}"
138+
echo ""
139+
140+
echo ""
141+
echo "Waiting for pods to start..."
142+
echo ""
143+
sleep 60s
144+
145+
# Get state of the k8s object. If numberReady == desiredNumberScheduled, consider the upgrade successful. Else raise error
146+
getStatus
147+
status="$(echo "${workloadStatus}" | jq '.status')"
148+
echo ""
149+
echo "${status}"
150+
echo ""
151+
152+
numberDesired="$(echo "${status}" | jq -r '.desiredNumberScheduled')"
153+
numberReady="$(echo "${status}" | jq -r '.numberReady')"
154+
155+
if (( numberReady == numberDesired )); then
156+
echo "${K8S_OBJECT_NAME} has been upgraded to ${DEPLOY_IMAGE}"
157+
158+
# If pods are not starting, rollback the upgrade and exit the build with error
159+
else
160+
echo "state = error...rolling back upgrade"
161+
updateObject "${ROLLBACK_IMAGE}"
162+
echo ""
163+
164+
echo ""
165+
echo "Waiting for rollback pods to start..."
166+
echo ""
167+
sleep 60s
168+
169+
getStatus
170+
status="$(echo "${workloadStatus}" | jq '.status')"
171+
echo ""
172+
echo "${status}"
173+
echo ""
174+
175+
numberDesired="$(echo "${status}" | jq -r '.desiredNumberScheduled')"
176+
numberReady="$(echo "${status}" | jq -r '.numberReady')"
177+
178+
if (( numberReady == numberDesired )); then
179+
echo "Rollback to ${ROLLBACK_IMAGE} completed."
180+
else
181+
echo "FATAL - rollback failed"
182+
fi
183+
echo "Exiting Build..."
184+
exit 1
185+
fi
186+
187+
else
188+
echo "This TAG is not in a valid format..."
189+
echo "Exiting Build..."
190+
exit 0
191+
fi
192+
echo "Exiting Build..."
193+
exit 0
194+
env:
195+
TAG: ${{ github.event.inputs.tag }}

0 commit comments

Comments
 (0)