Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit b0438de

Browse files
authored
CircleCi cleanup (#198)
* Changes nodeNo to nodeId * Replaces node3 with node4 * Updates circleci cleanup fn * Changes nodeId to jobId * FIxes parallel.sh * Renames job3 * Fixes lingering ref to node3 * Updates job1 name * Removes other unused job * Removes unnecesary docker petstore server in circleci
1 parent 3e03cf3 commit b0438de

File tree

2 files changed

+24
-135
lines changed

2 files changed

+24
-135
lines changed

.circleci/config.yml

+15-78
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ version: 2.1
22
commands: # a reusable command with parameters
33
command_build_and_test:
44
parameters:
5-
nodeNo:
6-
default: "0"
5+
jobId:
6+
default: "unset"
77
type: string
88
steps:
99
# Restore the dependency cache
@@ -13,17 +13,6 @@ commands: # a reusable command with parameters
1313
- source-v2-{{ .Branch }}-{{ .Revision }}
1414
- source-v2-{{ .Branch }}-
1515
- source-v2-
16-
# Machine Setup
17-
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
18-
- run:
19-
name: Install Headless Chrome dependencies
20-
command: |
21-
sudo apt-get update && sudo apt-get install -yq \
22-
gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
23-
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
24-
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 \
25-
libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates \
26-
fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm1
2716
# The following `checkout` command checks out your code to your working directory. In 1.0 we did this implicitly. In 2.0 you can choose where in the course of a job your code should be checked out.
2817
- checkout
2918
# Prepare for artifact and test results collection equivalent to how it was done on 1.0.
@@ -33,24 +22,10 @@ commands: # a reusable command with parameters
3322
# This is based on your 1.0 configuration file or project settings
3423
- run:
3524
command: java -version
36-
- run:
37-
command: 'sudo docker info >/dev/null 2>&1 || sudo service docker start; '
38-
- run:
39-
command: |-
40-
printf '127.0.0.1 petstore.swagger.io
41-
' | sudo tee -a /etc/hosts
42-
# - run: docker pull openapijsonschematools/openapi-petstore
43-
# - run: docker run -d -e OPENAPI_BASE_PATH=/v3 -e DISABLE_API_KEY=1 -e DISABLE_OAUTH=1 -p 80:8080 openapijsonschematools/openapi-petstore
44-
- run: docker pull swaggerapi/petstore
45-
- run: docker run --name petstore.swagger -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
46-
- run: docker ps -a
47-
- run: sleep 30
48-
- run: cat /etc/hosts
4925
# Test
50-
- run: mvn --no-snapshot-updates --quiet clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error
5126
- run:
5227
name: "Setup custom environment variables"
53-
command: echo 'export CIRCLE_NODE_INDEX="<<parameters.nodeNo>>"' >> $BASH_ENV
28+
command: echo 'export CIRCLE_JOB_ID="<<parameters.jobId>>"' >> $BASH_ENV
5429
- run: ./.circleci/parallel.sh
5530
# Save dependency cache
5631
- save_cache:
@@ -59,40 +34,33 @@ commands: # a reusable command with parameters
5934
# This is a broad list of cache paths to include many possible development environments
6035
# You can probably delete some of these entries
6136
- vendor/bundle
62-
- ~/.nvm
6337
- ~/.pyenv
6438
- ~/virtualenvs
6539
- ~/.m2
6640
- ~/.ivy2
6741
- ~/.sbt
6842
- ~/.bundle
69-
- ~/.go_workspace
7043
- ~/.gradle
7144
- ~/.cache/bower
7245
- ".git"
7346
- ~/.stack
74-
- ~/R
7547
# save "default" cache using the key "source-v2-"
7648
- save_cache:
7749
key: source-v2-
7850
paths:
7951
# This is a broad list of cache paths to include many possible development environments
8052
# You can probably delete some of these entries
8153
- vendor/bundle
82-
- ~/.nvm
8354
- ~/.pyenv
8455
- ~/virtualenvs
8556
- ~/.m2
8657
- ~/.ivy2
8758
- ~/.sbt
8859
- ~/.bundle
89-
- ~/.go_workspace
9060
- ~/.gradle
9161
- ~/.cache/bower
9262
- ".git"
9363
- ~/.stack
94-
- /home/circleci/OpenAPITools/openapi-json-schema-generator/samples/client/petstore/haskell-http-client/.stack-work
95-
- ~/R
9664
# Teardown
9765
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
9866
# Save test results
@@ -105,8 +73,8 @@ commands: # a reusable command with parameters
10573
path: /tmp/circleci-test-results
10674
command_docker_build_and_test:
10775
parameters:
108-
nodeNo:
109-
default: "0"
76+
jobId:
77+
default: "unset"
11078
type: string
11179
steps:
11280
# Machine Setup
@@ -117,15 +85,9 @@ commands: # a reusable command with parameters
11785
# In many cases you can simplify this from what is generated here.
11886
# 'See docs on artifact collection here https://circleci.com/docs/2.0/artifacts/'
11987
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
120-
# This is based on your 1.0 configuration file or project settings
121-
# - run:
122-
# command: sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java; sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac; echo -e "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64" >> $BASH_ENV
123-
# - run:
124-
# Test
125-
# - run: mvn --no-snapshot-updates --quiet clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error
12688
- run:
12789
name: "Setup custom environment variables"
128-
command: echo 'export CIRCLE_NODE_INDEX="<<parameters.nodeNo>>"' >> $BASH_ENV
90+
command: echo 'export CIRCLE_JOB_ID="<<parameters.jobId>>"' >> $BASH_ENV
12991
- run: ./.circleci/parallel.sh
13092
# Teardown
13193
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
@@ -138,18 +100,7 @@ commands: # a reusable command with parameters
138100
- store_artifacts:
139101
path: /tmp/circleci-test-results
140102
jobs:
141-
node0:
142-
machine:
143-
image: ubuntu-2004:202201-02
144-
working_directory: ~/OpenAPITools/openapi-json-schema-generator
145-
shell: /bin/bash --login
146-
environment:
147-
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
148-
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
149-
steps:
150-
- command_build_and_test:
151-
nodeNo: "0"
152-
node1:
103+
ensureSamplesAndGeneratorDocsUpToDate:
153104
machine:
154105
image: ubuntu-2004:202201-02
155106
working_directory: ~/OpenAPITools/openapi-json-schema-generator
@@ -159,8 +110,8 @@ jobs:
159110
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
160111
steps:
161112
- command_build_and_test:
162-
nodeNo: "1"
163-
node2:
113+
jobId: "ensureSamplesAndGeneratorDocsUpToDate"
114+
mvnCleanInstall:
164115
machine:
165116
image: ubuntu-2004:202201-02
166117
working_directory: ~/OpenAPITools/openapi-json-schema-generator
@@ -170,20 +121,8 @@ jobs:
170121
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
171122
steps:
172123
- command_build_and_test:
173-
nodeNo: "2"
174-
node3:
175-
machine:
176-
image: ubuntu-2004:202201-02
177-
working_directory: ~/OpenAPITools/openapi-json-schema-generator
178-
shell: /bin/bash --login
179-
environment:
180-
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
181-
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
182-
steps:
183-
- checkout
184-
- command_build_and_test:
185-
nodeNo: "3"
186-
node4:
124+
jobId: "mvnCleanInstall"
125+
testPythonClientSamples:
187126
docker:
188127
- image: python:3.8
189128
working_directory: ~/OpenAPITools/openapi-json-schema-generator
@@ -194,13 +133,11 @@ jobs:
194133
steps:
195134
- checkout
196135
- command_docker_build_and_test:
197-
nodeNo: "4"
136+
jobId: "testPythonClientSamples"
198137
workflows:
199138
version: 2
200139
build:
201140
jobs:
202-
- node0
203-
- node1
204-
- node2
205-
- node3
206-
- node4
141+
- ensureSamplesAndGeneratorDocsUpToDate
142+
- mvnCleanInstall
143+
- testPythonClientSamples

.circleci/parallel.sh

+9-57
Original file line numberDiff line numberDiff line change
@@ -3,77 +3,29 @@
33
# A bash script to run CircleCI node/test in parallel
44
#
55

6-
NODE_INDEX=${CIRCLE_NODE_INDEX:-0}
6+
JOB_ID=${CIRCLE_JOB_ID:-"unset"}
77

88
set -e
99

1010
export NODE_ENV=test
1111

12-
function cleanup {
13-
# Show logs of 'petstore.swagger' container to troubleshoot Unit Test failures, if any.
14-
if [ "$NODE_INDEX" != "4" ]; then
15-
docker logs petstore.swagger # container name specified in circle.yml
16-
fi
17-
}
18-
19-
trap cleanup EXIT
20-
21-
if [ "$NODE_INDEX" = "1" ]; then
22-
# node1
23-
# ensures samples + docs up to date
24-
echo "Running node $NODE_INDEX"
25-
12+
if [ "$JOB_ID" = "ensureSamplesAndGeneratorDocsUpToDate" ]; then
13+
echo "Running job $JOB_ID"
2614
./bin/utils/ensure-up-to-date
2715

28-
elif [ "$NODE_INDEX" = "2" ]; then
29-
# node2
30-
echo "Running node $NODE_INDEX"
31-
32-
elif [ "$NODE_INDEX" = "3" ]; then
33-
# node3
34-
35-
echo "Running node $NODE_INDEX to test 'samples.circleci.node3' defined in pom.xml ..."
36-
#wget https://www.python.org/ftp/python/3.8.9/Python-3.8.9.tgz
37-
#tar -xf Python-3.8.9.tgz
38-
#cd Python-3.8.9
39-
#./configure --enable-optimizations
40-
#sudo make altinstall
41-
pyenv install --list
42-
pyenv install 3.6.3
43-
pyenv install 2.7.14
44-
pyenv global 3.6.3
45-
46-
# Install node@stable (for angular 6)
47-
set +e
48-
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
49-
export NVM_DIR="/opt/circleci/.nvm"
50-
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
51-
#nvm install stable
52-
# install v16 instead of the latest stable version
53-
nvm install 16
54-
nvm alias default 16
55-
node --version
56-
57-
# Each step uses the same `$BASH_ENV`, so need to modify it
58-
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
59-
echo "[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"" >> $BASH_ENV
60-
61-
# no longer testing python-prior
62-
#mvn --no-snapshot-updates --quiet verify -Psamples.circleci.node3 -Dorg.slf4j.simpleLogger.defaultLogLevel=error
63-
64-
elif [ "$NODE_INDEX" = "4" ]; then
65-
# node4
66-
67-
echo "Running node $NODE_INDEX to test 'samples.circleci.node4' defined in pom.xml ..."
16+
elif [ "$JOB_ID" = "mvnCleanInstall" ]; then
17+
echo "Running job $JOB_ID"
18+
mvn --no-snapshot-updates --quiet clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error
6819

69-
#mvn --no-snapshot-updates --quiet verify -Psamples.circleci.node4 -Dorg.slf4j.simpleLogger.defaultLogLevel=error
20+
elif [ "$JOB_ID" = "testPythonClientSamples" ]; then
21+
echo "Running job $JOB_ID ..."
7022
(cd samples/client/petstore/python && make test)
7123
(cd samples/client/3_0_3_unit_test/python && make test)
7224
(cd samples/client/openapi_features/nonCompliantUseDiscriminatorIfCompositionFails/python && make test)
7325
(cd samples/client/openapi_features/security/python && make test)
7426

7527
else
76-
echo "Running node $NODE_INDEX"
28+
echo "Running job $JOB_ID"
7729

7830
fi
7931

0 commit comments

Comments
 (0)