Skip to content
This repository was archived by the owner on Aug 26, 2020. It is now read-only.

Commit ef02b20

Browse files
author
Luis Fabregas
committed
Merge branch 'release'
2 parents 47fe3a3 + 4503c75 commit ef02b20

268 files changed

Lines changed: 6832 additions & 4010 deletions

File tree

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- release
8+
9+
jobs:
10+
build:
11+
name: CI
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout trigger commit
15+
uses: actions/checkout@v1
16+
- name: Install dependencies
17+
run: |
18+
sudo apt-get install -y openvpn openconnect
19+
- name: Prepare VM
20+
if: success()
21+
run: |
22+
rm -f -r ./.git
23+
echo "${{ secrets.GATEWAY_KEY }}" > ~/sshkey
24+
sudo chmod 600 ~/sshkey
25+
- name: Establish VPN connection
26+
if: success()
27+
run: |
28+
# Force returning packets to be routed over public interface and not over the VPN
29+
sudo ip rule add from $(ip route get 1 | grep -Po '(?<=src )(\S+)') table 128
30+
sudo ip route add table 128 to $(ip route get 1 | grep -Po '(?<=src )(\S+)')/32 dev $(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)')
31+
sudo ip route add table 128 default via $(ip -4 route ls | grep default | grep -Po '(?<=via )(\S+)')
32+
# Start network tunnel (TUN) device
33+
sudo openvpn --mktun --dev tun1
34+
sudo ifconfig tun1 up
35+
# Launch VPN connection
36+
echo "${{ secrets.VPN_PASSWD }}" | sudo openconnect ${{ secrets.VPN_SERVER }} --user=${{ secrets.VPN_USER }} --background --passwd-on-stdin
37+
- name: Transfer source files to CI-server
38+
if: success()
39+
run: |
40+
scp -o StrictHostKeyChecking=no -i ~/sshkey -P ${{ secrets.GATEWAY_PORT }} -r ../DeerAnalysis2 ${{ secrets.GATEWAY_HOST }}:/home/lufa/scp_traffic/
41+
ssh -o StrictHostKeyChecking=no -i ~/sshkey -p ${{ secrets.GATEWAY_PORT }} ${{ secrets.GATEWAY_HOST }} scp -r /home/lufa/scp_traffic/DeerAnalysis2 ${{ secrets.CISERVER_HOST }}:/home/deeranalysis/
42+
ssh -o StrictHostKeyChecking=no -i ~/sshkey -p ${{ secrets.GATEWAY_PORT }} ${{ secrets.GATEWAY_HOST }} "rm -f -r /home/lufa/scp_traffic/DeerAnalysis2"
43+
- name: Run test suite connected to CI-Server
44+
if: success()
45+
run: |
46+
ssh -tt -o StrictHostKeyChecking=no -i ~/sshkey -p ${{ secrets.GATEWAY_PORT }} -t ${{ secrets.GATEWAY_HOST }} ssh ${{ secrets.CISERVER_HOST }} << EOF
47+
#Run test suite
48+
cd DeerAnalysis2/build
49+
matlab -nodesktop -r "datestsuite;exit"
50+
python3 uploadS3.py --keyfile ~/.ssh/aws_access_keys.txt --file "coverage_badge.json" --bucket deershields
51+
python3 uploadS3.py --keyfile ~/.ssh/aws_access_keys.txt --file "testsuite_badge.json" --bucket deershields
52+
#Transfer log file to the gateway
53+
scp -o StrictHostKeyChecking=no -i ~/.ssh/gateway_key -P ${{ secrets.GATEWAY_PORT }} ./datestsuite.error ${{ secrets.GATEWAY_HOST }}:/home/lufa/scp_traffic/ || true
54+
#Delete the source files
55+
cd /home/deeranalysis/
56+
rm -f -r DeerAnalysis2
57+
EOF
58+
- name: Disconnect CI-server
59+
if: success()
60+
run: |
61+
#Transfer log file to GitHub VM
62+
scp -o StrictHostKeyChecking=no -i ~/sshkey -P ${{ secrets.GATEWAY_PORT }} ${{ secrets.GATEWAY_HOST }}:/home/lufa/scp_traffic/datestsuite.error ~/ || true
63+
ssh -o StrictHostKeyChecking=no -i ~/sshkey -p ${{ secrets.GATEWAY_PORT }} ${{ secrets.GATEWAY_HOST }} "rm -f /home/lufa/scp_traffic/datestsuite.error" || true
64+
rm -f ~/sshkey
65+
- name: All tests passed successfully
66+
if: success()
67+
run: |
68+
! [ -f ~/datestsuite.error ] && echo "Test suite passed" || (echo "Test suite failed" && deerfailed)
69+
- name: Disconnect VPN connection
70+
if: always()
71+
run: |
72+
#Ensure the VPN is disconnected by killing openconnect
73+
sudo pkill openconnect
74+
#Remove TUN device
75+
sudo ifconfig tun1 down
76+
sudo openvpn --rmtun --dev tun1

.github/workflows/docbuilder.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ jobs:
3636
sphinx-build -E -b html ./source ../docs
3737
- name: Connect and update DeerAnalysis AWS S3 Bucket
3838
run: |
39-
cd docsrc
40-
python -m websynch -k ${{ secrets.S3_ACCESS }} -s ${{ secrets.S3_SECRETACCESS }}
39+
cd build
40+
python -m websynch -k ${{ secrets.S3_ACCESS }} -s ${{ secrets.S3_SECRETACCESS }} -d "../docs" --bucket deeranalysis.org

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ cvx/
33
docs/docsrc/build/
44
docs/docsrc/venv/
55
docsrc/venv/
6+
docsrc/source/.doctrees
67
docs/
78
docsrc/cache/
89
docsrc/source/__pycache__/
910
docsrc/aws_access_keys.txt
1011
docsrc/__pycache__/
1112
build/.ssh/
13+
tutorials/**/*.pdf

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<img src="https://img.shields.io/badge/MATLAB-R2016b--R2019b-brightgreen?style=flat"></img>
1010
<img src="https://img.shields.io/github/downloads/luisfabib/DeerAnalysis2/total?style=flat"></img>
1111
<img src="https://github.com/luisfabib/DeerAnalysis2/workflows/Webpage%20update/badge.svg?style=flat-square"></img>
12+
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeershields.s3.eu-central-1.amazonaws.com%2Fcoverage_badge.json"></img>
13+
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeershields.s3.eu-central-1.amazonaws.com%2Ftestsuite_badge.json"></img>
1214
</p>
1315

1416
### About

build/CI_testing.m

Lines changed: 0 additions & 7 deletions
This file was deleted.

build/build_ssh_euler.bat

Lines changed: 0 additions & 13 deletions
This file was deleted.

build/compiletutorials.m

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
clc
3+
4+
files = dir('../tutorials/**/*.mlx');
5+
sourcenames = {files.name};
6+
pdfnames = cellfun(@(S)[S(1:end-3) 'pdf'],sourcenames,'UniformOutput',false);
7+
htmlnames = cellfun(@(S)[S(1:end-3) 'html'],sourcenames,'UniformOutput',false);
8+
mnames = cellfun(@(S)[S(1:end-3) 'm'],sourcenames,'UniformOutput',false);
9+
10+
paths = {files.folder};
11+
sourcefiles = cellfun(@(x,y)fullfile(x,y),paths,sourcenames,'UniformOutput',false);
12+
pdffiles = cellfun(@(x,y)fullfile(x,y),paths,pdfnames,'UniformOutput',false);
13+
htmlfiles = cellfun(@(x,y)fullfile(x,y),paths,htmlnames,'UniformOutput',false);
14+
mfiles = cellfun(@(x,y)fullfile(x,y),paths,mnames,'UniformOutput',false);
15+
16+
%Convert live script into other formats
17+
for i=1:numel(pdfnames)
18+
fprintf('Conversion: mlx -> pdf (file %i of %i)...',i,numel(sourcefiles))
19+
matlab.internal.liveeditor.openAndConvert(sourcefiles{i},pdffiles{i});
20+
fprintf(' complete \n')
21+
end
22+
23+
for i=1:numel(htmlnames)
24+
fprintf('Conversion: mlx -> html (file %i of %i)...',i,numel(sourcefiles))
25+
matlab.internal.liveeditor.openAndConvert(sourcefiles{i},htmlfiles{i});
26+
fprintf(' complete \n')
27+
end
28+
29+
for i=1:numel(mnames)
30+
fprintf('Conversion: mlx -> m (file %i of %i)...',i,numel(sourcefiles))
31+
matlab.internal.liveeditor.openAndConvert(sourcefiles{i},mfiles{i});
32+
fprintf(' complete \n')
33+
end
34+
35+
36+
if ispc
37+
38+
%Synchronize the AWS bucket
39+
system('python synchS3.py --keyfile %USERPROFILE%\.ssh\aws_access_keys.txt --directory "../tutorials" --bucket deertutorials');
40+
41+
%Delete files
42+
for i=1:numel(pdfnames)
43+
fprintf('Deleting: pdf (file %i of %i)...',i,numel(sourcefiles))
44+
delete(pdffiles{i});
45+
fprintf(' complete \n')
46+
end
47+
48+
for i=1:numel(mnames)
49+
fprintf('Deleting: m (file %i of %i)...',i,numel(sourcefiles))
50+
delete(mfiles{i});
51+
fprintf(' complete \n')
52+
end
53+
54+
end

build/datestsuite.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
%Add paths to dependencies
2+
addpath('../functions')
3+
addpath('../functions/models')
4+
addpath('../tests')
5+
addpath('../tests/comparison')
6+
7+
%Run full test suite
8+
Out = datest('--time','--perform','--coverage','--badges');
9+
10+
if Out.Errors>0
11+
logname = 'datestsuite.error';
12+
save(logname)
13+
end
14+
15+
%Load the badges JSON endpoints to AWS
16+
if ispc
17+
system('python uploadS3.py --keyfile %USERPROFILE%\.ssh\aws_access_keys.txt --file "coverage_badge.json" --bucket deershields')
18+
system('python uploadS3.py --keyfile %USERPROFILE%\.ssh\aws_access_keys.txt --file "testsuite_badge.json" --bucket deershields')
19+
20+
%Delete files once uploaded
21+
delete('coverage_badge.json')
22+
delete('testsuite_badge.json')
23+
24+
elseif isunix
25+
%system('python3 uploadS3.py --keyfile ~/.ssh/aws_access_keys.txt --file "coverage_badge.json" --bucket deershields')
26+
%system('python3 uploadS3.py --keyfile ~/.ssh/aws_access_keys.txt --file "testsuite_badge.json" --bucket deershields')
27+
elseif ismac
28+
error('macOS is not supported')
29+
end

build/euler_build.bash

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
parser = ArgumentParser()
1414
parser.add_argument("-k", "--key",dest="accesskey",default=[],help="AWS Access Key")
1515
parser.add_argument("-s", "--secretkey",dest="secretkey", default=[],help="AWS Secret Access Key")
16+
parser.add_argument("-d", "--directory",dest="base_dir",default=[],help="Directory to upload")
17+
parser.add_argument("-b", "--bucket",dest="bucketname", default=[],help="Name of S3 bucket")
18+
parser.add_argument("-i", "--keyfile",dest="keyfile",default=[],help="AWS Access Key")
1619
args = parser.parse_args()
1720

1821
def getListOfFiles(dirName):
@@ -55,13 +58,21 @@ def metadataType(file):
5558

5659
#If access codes have not been passed as inputs then check if file is there
5760
if not args.accesskey or not args.secretkey:
61+
62+
if not args.keyfile:
63+
keypath = 'aws_access_keys.txt'
64+
else:
65+
keypath = args.keyfile
66+
67+
#Set absolute path to key file
68+
#cwd = os.getcwd()
69+
#keypath = os.path.join(cwd,keypath)
5870

5971
#Load and read the secure access keys to connect to the AWS S3 client
60-
if os.path.isfile(".\aws_access_keys.txt"):
72+
if not os.path.isfile(keypath):
6173
print("AWS access keys not found. You may not have rights to request this action.")
6274
exit()
63-
64-
with open('aws_access_keys.txt', 'r') as file:
75+
with open(keypath, 'r') as file:
6576
AccessKeys = [line.rstrip('\n') for line in file]
6677
else:
6778
AccessKeys = [args.accesskey, args.secretkey]
@@ -78,24 +89,27 @@ def metadataType(file):
7889
aws_access_key_id = AccessKeys[0],
7990
aws_secret_access_key = AccessKeys[1],
8091
region_name='eu-west-1')
81-
bucket = s3.Bucket('deeranalysis.org')
8292

83-
base_dir = "../docs"
93+
bucketname = str(args.bucketname)
94+
bucket = s3.Bucket(bucketname)
95+
96+
base_dir = str(args.base_dir)
8497
#Get full list of local files
8598
localFiles = getListOfFiles(base_dir)
99+
base_dir += '/'
86100

87101
for key in bucket.objects.all():
88102

89103
#Get full local path of current file in bucket
90104
file = '/'.join([base_dir, key.key])
91-
105+
92106
#Remove bucket file from list of local files
93107
if file in localFiles: localFiles.remove(file)
94108

95109
#If file has been removed from the local source, remove it from the bucket
96110
if not os.path.isfile(file):
97111
print("Removing ",file," from bucket, not found in local source...")
98-
s3_client.delete_object(Bucket='deeranalysis.org',Key = key.key)
112+
s3_client.delete_object(Bucket=bucketname,Key = key.key)
99113
continue
100114

101115
#Get last modified date of local files
@@ -107,13 +121,14 @@ def metadataType(file):
107121

108122
#Update the file if the local source file is newer than the version in the S3 bucket
109123
if modifyDate > key.last_modified:
110-
print("Updating", file, "in web bucket... ")
111-
s3.meta.client.upload_file(file, 'deeranalysis.org', key.key, ExtraArgs={'ContentType': metadataType(file)} )
124+
print("Updating", file, "in ",bucketname," bucket... ")
125+
s3.meta.client.upload_file(file, bucketname, key.key, ExtraArgs={'ContentType': metadataType(file)} )
112126

113127
#Add the remaining local files which are still not on the we bucket
114128
for files in localFiles:
115-
key = files.replace("../docs/","")
116-
print("Adding", key, "to web bucket... ")
117-
s3.meta.client.upload_file(file, 'deeranalysis.org', key, ExtraArgs={'ContentType': metadataType(file)} )
129+
file = files;
130+
key = files.replace(base_dir,"")
131+
print("Adding", key, "to",bucketname,"bucket... ")
132+
s3.meta.client.upload_file(file, bucketname, key, ExtraArgs={'ContentType': metadataType(str(key))} )
118133

119-
print("Finished: AWS S3 DeerAnalysis.org bucket is up to date.")
134+
print("Finished: AWS S3 ",bucketname," bucket is up to date.")

0 commit comments

Comments
 (0)