Skip to content

Commit e3ea37e

Browse files
authored
new CI (#6)
* new CI
1 parent a3674c7 commit e3ea37e

File tree

1 file changed

+36
-64
lines changed

1 file changed

+36
-64
lines changed

.circleci/config.yml

Lines changed: 36 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ version: 2.1
33

44
orbs:
55
aws-s3: circleci/aws-s3@3.0.0
6+
colcon_build-orb: cmrobotics/colcon_build-orb@0.2.1
7+
openvpn3: versatile/openvpn3@1.0.19
68

79
workflows:
810
build, test and create:
911
jobs:
1012
- build-test:
1113
filters:
1214
tags:
13-
ignore: /[0-9]*\.[0-9]*\.[0-9]/
15+
ignore: /^[0-9]+\.[0-9]+\.[0-9]+$/
1416
context:
1517
- ROS Pipelines
1618
- OpenVPN
@@ -19,15 +21,15 @@ workflows:
1921
- build-test
2022
context:
2123
- ROS Pipelines
22-
24+
- OpenVPN
2325
build, test, create and deploy:
2426
jobs:
2527
- build-test:
2628
filters:
2729
branches:
2830
ignore: /.*/
2931
tags:
30-
only: /[0-9]*\.[0-9]*\.[0-9]/
32+
only: /^[0-9]+\.[0-9]+\.[0-9]+$/
3133
context:
3234
- ROS Pipelines
3335
- OpenVPN
@@ -36,17 +38,18 @@ workflows:
3638
branches:
3739
ignore: /.*/
3840
tags:
39-
only: /[0-9]*\.[0-9]*\.[0-9]/
41+
only: /^[0-9]+\.[0-9]+\.[0-9]+$/
4042
requires:
4143
- build-test
4244
context:
4345
- ROS Pipelines
46+
- OpenVPN
4447
- deploy:
4548
filters:
4649
branches:
4750
ignore: /.*/
4851
tags:
49-
only: /[0-9]*\.[0-9]*\.[0-9]/
52+
only: /^[0-9]+\.[0-9]+\.[0-9]+$/
5053
requires:
5154
- build-test
5255
- create
@@ -57,87 +60,54 @@ executors:
5760
simple-machine:
5861
machine:
5962
image: ubuntu-2004:202111-02
60-
working_directory: ~/workspace/src/linak_actuator_modbus
63+
working_directory: ~/workspace/src/cmr_tests_utils
6164
simple-docker:
6265
docker:
63-
- image: gallaisoma/ros2-galactic:latest
66+
- image: osrf/ros:galactic-desktop-focal
6467
working_directory: ~/workspace/src/cmr_tests_utils
6568
jobs:
6669
build-test:
6770
executor: simple-machine
6871
steps:
6972
- checkout:
7073
path: ~/workspace/src/$CIRCLE_PROJECT_REPONAME
71-
- run:
72-
name: Install OpenVPN3
73-
command: |
74-
sudo apt update && sudo apt install apt-transport-https
75-
sudo wget https://swupdate.openvpn.net/repos/openvpn-repo-pkg-key.pub
76-
sudo apt-key add openvpn-repo-pkg-key.pub
77-
sudo wget -O /etc/apt/sources.list.d/openvpn3.list https://swupdate.openvpn.net/community/openvpn3/repos/openvpn3-focal.list
78-
sudo apt update && sudo apt install openvpn3
79-
- run:
80-
name: VPN setup
81-
background: true
82-
command: |
83-
echo $VPN_CLIENT_CONFIG | base64 --decode > /tmp/config.ovpn
84-
phone_home=$(ss -Hnto state established '( sport = :ssh )' | head -n1 | awk '{ split($4, a, ":"); print a[1] }')
85-
echo $phone_home
86-
if [ -n "$phone_home" ]; then
87-
echo -e "\nroute $phone_home 255.255.255.255 net_gateway" >> /tmp/config.ovpn
88-
fi
89-
echo "\nroute 169.254.0.0 255.255.0.0 net_gateway" >> /tmp/config.ovpn
90-
sudo openvpn3 session-start --config /tmp/config.ovpn > /tmp/openvpn.log
91-
- run:
92-
name: Wait for the connection to be established and check
93-
command: |
94-
until sudo openvpn3 sessions-list|grep "Client connected"; do
95-
echo "Attempting to connect to VPN server..."
96-
sleep 1;
97-
done
98-
- run:
99-
name: Start Docker
100-
command: |
101-
docker pull gallaisoma/ros2-galactic:latest
102-
docker run -e ROSDISTRO_INDEX_URL=$ROSDISTRO_INDEX_URL -v ~/workspace/src/$CIRCLE_PROJECT_REPONAME:/root/workspace/src/$CIRCLE_PROJECT_REPONAME --name ci_fun -dit gallaisoma/ros2-galactic:latest
103-
- run:
104-
name: Run build and test inside docker
105-
command: docker exec -it ci_fun /bin/bash -c " source /opt/ros/galactic/setup.bash && cd ~/workspace && curl -o aptly_repo_signing.key http://172.31.46.198/aptly_repo_signing.key && apt-key add aptly_repo_signing.key && echo 'deb http://172.31.46.198/ focal main' >> /etc/apt/sources.list && apt update && rosdep init && rosdep update && rosdep install --from-paths src --ignore-src -r -y && colcon build --packages-up-to $CIRCLE_PROJECT_REPONAME && source install/setup.bash "
106-
- run:
107-
name: Disconnect from OpenVPN
108-
command: |
109-
SESSION_PATH=$(sudo openvpn3 sessions-list | grep Path | awk -F': ' '{print $2}')
110-
echo $SESSION_PATH
111-
sudo openvpn3 session-manage --session-path $SESSION_PATH --disconnect
112-
when: always
113-
74+
- openvpn3/install
75+
- openvpn3/connect:
76+
config: VPN_CLIENT_CONFIG
77+
- openvpn3/check
78+
- colcon_build-orb/docker_run:
79+
rosdistro_url: ROSDISTRO_INDEX_URL
80+
github_token: GITHUB_TOKEN
81+
circle_project_repo: CIRCLE_PROJECT_REPONAME
82+
workspace_volume: /home/circleci/workspace:/root/workspace
83+
- colcon_build-orb/colcon_build
84+
- openvpn3/disconnect
11485
- persist_to_workspace:
11586
root: ../..
11687
paths:
11788
- .
11889
create:
119-
executor: simple-docker
90+
executor: simple-machine
12091
steps:
12192
- attach_workspace:
12293
at: ~/workspace
123-
- run:
124-
name: Deploy the deb artifact
125-
command: |
126-
cd ~/workspace
127-
mkdir ~/.ssh/
128-
ssh-keyscan github.com >> ~/.ssh/known_hosts
129-
git clone git@github.com:cmrobotics/pipeline_scripts.git
130-
cd ~/workspace/pipeline_scripts
131-
./binarization.sh
132-
94+
- openvpn3/install
95+
- openvpn3/connect:
96+
config: VPN_CLIENT_CONFIG
97+
- openvpn3/check
98+
- colcon_build-orb/docker_run:
99+
rosdistro_url: ROSDISTRO_INDEX_URL
100+
github_token: GITHUB_TOKEN
101+
circle_project_repo: CIRCLE_PROJECT_REPONAME
102+
workspace_volume: /home/circleci/workspace:/root/workspace
103+
- colcon_build-orb/binarize
104+
- openvpn3/disconnect
133105
- store_artifacts:
134106
path: ~/workspace/src/ros-galactic-cmr_tests_utils.deb
135-
136107
- persist_to_workspace:
137108
root: ~/workspace
138109
paths:
139110
- src/ros-galactic-cmr_tests_utils.deb
140-
141111
deploy:
142112
executor: simple-docker
143113
steps:
@@ -146,6 +116,9 @@ jobs:
146116
- run:
147117
name: Renaming with tag name
148118
command: mv ~/workspace/src/ros-galactic-$CIRCLE_PROJECT_REPONAME.deb ~/workspace/src/ros-galactic-$CIRCLE_PROJECT_REPONAME-$CIRCLE_TAG.deb
119+
- run:
120+
name: Install unzip
121+
command: apt update && apt install -y unzip
149122
- aws-s3/copy:
150123
arguments: |
151124
--acl private
@@ -154,4 +127,3 @@ jobs:
154127
aws-secret-access-key: AWS_SECRET_ACCESS_KEY
155128
from: ~/workspace/src/ros-galactic-$CIRCLE_PROJECT_REPONAME-$CIRCLE_TAG.deb
156129
to: 's3://aptly-debian-files/ros-galactic-$CIRCLE_PROJECT_REPONAME.deb'
157-

0 commit comments

Comments
 (0)