Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
ImreKertesz committed Nov 15, 2023
2 parents 604c568 + 5225d71 commit e9c9423
Show file tree
Hide file tree
Showing 4 changed files with 260 additions and 16 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/clone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: GitHub Clone Count Update Everyday

on:
schedule:
- cron: "10 0 * * *"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: gh login
run: echo "${{ secrets.SECRET_TOKEN }}" | gh auth login --with-token

- name: parse latest clone count
run: |
curl --user "${{ github.actor }}:${{ secrets.SECRET_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/traffic/clones \
> clone.json
- name: create gist and download previous count
id: set_id
run: |
if gh secret list | grep -q "GIST_ID"
then
echo "GIST_ID found"
echo ::set-output name=GIST::${{ secrets.GIST_ID }}
curl https://gist.githubusercontent.com/${{ github.actor }}/${{ secrets.GIST_ID }}/raw/clone.json > clone_before.json
if cat clone_before.json | grep '404: Not Found'; then
echo "GIST_ID not valid anymore. Creating another gist..."
gist_id=$(gh gist create clone.json | awk -F / '{print $NF}')
echo $gist_id | gh secret set GIST_ID
echo ::set-output name=GIST::$gist_id
cp clone.json clone_before.json
git rm --ignore-unmatch CLONE.md
fi
else
echo "GIST_ID not found. Creating a gist..."
gist_id=$(gh gist create clone.json | awk -F / '{print $NF}')
echo $gist_id | gh secret set GIST_ID
echo ::set-output name=GIST::$gist_id
cp clone.json clone_before.json
fi
- name: update clone.json
run: |
curl https://raw.githubusercontent.com/MShawon/github-clone-count-badge/master/main.py > main.py
python3 main.py
- name: Update gist with latest count
run: |
content=$(sed -e 's/\\/\\\\/g' -e 's/\t/\\t/g' -e 's/\"/\\"/g' -e 's/\r//g' "clone.json" | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
echo '{"description": "${{ github.repository }} clone statistics", "files": {"clone.json": {"content": "'"$content"'"}}}' > post_clone.json
curl -s -X PATCH \
--user "${{ github.actor }}:${{ secrets.SECRET_TOKEN }}" \
-H "Content-Type: application/json" \
-d @post_clone.json https://api.github.com/gists/${{ steps.set_id.outputs.GIST }} > /dev/null 2>&1
if [ ! -f CLONE.md ]; then
shields="https://img.shields.io/badge/dynamic/json?color=success&label=Clone&query=count&url="
url="https://gist.githubusercontent.com/${{ github.actor }}/${{ steps.set_id.outputs.GIST }}/raw/clone.json"
repo="https://github.com/MShawon/github-clone-count-badge"
echo ''> CLONE.md
echo '
**Markdown**
```markdown' >> CLONE.md
echo "[![GitHub Clones]($shields$url&logo=github)]($repo)" >> CLONE.md
echo '
```
**HTML**
```html' >> CLONE.md
echo "<a href='$repo'><img alt='GitHub Clones' src='$shields$url&logo=github'></a>" >> CLONE.md
echo '```' >> CLONE.md
git add CLONE.md
git config --global user.name "GitHub Action"
git config --global user.email "[email protected]"
git commit -m "create clone count badge"
fi
- name: Push
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
29 changes: 16 additions & 13 deletions Contributor-License-Agreement.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Contributor License Agreement
=============================
Version 1.1 (2022-09-21)

This AGREEMENT is made by and between the

Expand All @@ -10,16 +11,18 @@ and

each GitHub User listed in the following table:

Name | Company/Institution/Address | City | Country | E-Mail/GitHub Username
------------------------ | ---------------------------------- | --------- | ------- | ----------------------
Lars Kasper | TNU, University of Zurich | Zurich | CH | mrikasper
Eduardo Aponte | TNU, University of Zurich | Zurich | CH | tnutapas
Daniel Hoffmann Ayala | Technical University | Munich | D | DanielHoffmannAyala
Benoît Béranger | CENIR, ICM | Paris | FR | benoitberanger
Stephan Heunis | Eindhoven University of Technology | Eindhoven | NL | jsheunis
Niklas Bürgi | SNS, University of Zurich | Zurich | CH | nbuergi
Alexandre Sayal | CIBIT, University of Coimbra | Coimbra | PT | alexsayal
**- Add Entry here -** | **- Add Entry here -** | **Add** | **Add** | **Add**
Name | Company/Institution/Address | City | Country | E-Mail/GitHub Username | CLA version accepted
------------------------ | ---------------------------------- | --------- | ------- | ---------------------- | ------------------
Lars Kasper | TNU, University of Zurich | Zurich | CH | mrikasper | 1.0
Eduardo Aponte | TNU, University of Zurich | Zurich | CH | tnutapas | 1.0
Daniel Hoffmann Ayala | Technical University | Munich | D | DanielHoffmannAyala | 1.0
Benoît Béranger | CENIR, ICM | Paris | FR | benoitberanger | 1.0
Stephan Heunis | Eindhoven University of Technology | Eindhoven | NL | jsheunis | 1.0
Niklas Bürgi | SNS, University of Zurich | Zurich | CH | nbuergi | 1.0
Alexandre Sayal | CIBIT, University of Coimbra | Coimbra | PT | alexsayal | 1.0
Matthias Müller-Schrader | TNU, University of Zurich | Zurich | CH | mms-neuro | 1.1
Saskia Bollmann | The University of Queensland | Brisbane | AUS | SaskiaBollmann | 1.1
**- Add Entry here -** | **- Add Entry here -** | **Add** | **Add** | **Add** | 1.1

(hereinafter referred to as "Contributor")

Expand All @@ -41,7 +44,7 @@ TERMS AND CONDITIONS

1.1 "Contribution" means any source code, object code, patch, tool, sample, graphic, specification, manual, documentation, or any other material posted or submitted by Contributor to the Project.

1.2 "Agreement" shall mean this document as signed by the authorized official of the Contributor.
1.2 "Agreement" shall mean this document.

2. Grant/Scope of License

Expand All @@ -60,7 +63,7 @@ TERMS AND CONDITIONS

4. Rights of Contributor

Except as set out above, Contributor keeps all right, title, and interest in Contributions. The rights that Contributor grants to University of Zurich under these terms are effective on the date Contributor first submitted a contribution to University of Zurich, even if Contributor's submission took place before the date Contributor signs this Agreement. Any contribution University of Zurich makes available under any license will also be made available under a suitable FSF (Free Software Foundation) or OSI (Open Source Initiative) approved license.
Except as set out above, Contributor keeps all right, title, and interest in Contributions. The rights that Contributor grants to University of Zurich under these terms are effective on the date Contributor first submitted a contribution to University of Zurich, even if Contributor's submission took place before the date Contributor accepts this Agreement. Any contribution University of Zurich makes available under any license will also be made available under a suitable FSF (Free Software Foundation) or OSI (Open Source Initiative) approved license.

5. Warranty

Expand All @@ -69,7 +72,7 @@ TERMS AND CONDITIONS
- to the best of Contributor's knowledge, each contribution will not violate any third party's copyrights, trademarks, patents, or other intellectual property rights; and
- each contribution shall be in compliance with applicable export and import laws.

5.2 Contributor agrees to notify University of Zurich if Contributor becomes aware of any circumstance which would make any of the foregoing representations inaccurate in any respect. University of Zurich may publicly disclose Contributor's participation in the project, including the fact that Contributor has signed this Agreement.
5.2 Contributor agrees to notify University of Zurich if Contributor becomes aware of any circumstance which would make any of the foregoing representations inaccurate in any respect. University of Zurich may publicly disclose Contributor's participation in the project, including the fact that Contributor has accepted this Agreement.

6. Miscellaneous

Expand Down
11 changes: 8 additions & 3 deletions misc/tapas_get_toolbox_infos.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,23 @@
%% Order determines init-order: do that by alphabet for main toolboxes
infos = tapas_default_toolbox_info(infos, 'ceode');

infos.hgf.init_function = '';
infos.hgf.init_function = '';
infos.hgf.init_dir = 'HGF';
infos.hgf.dependencies = [];
infos.hgf.diagnose_files = '';
infos.hgf.test_function_name = '';

infos.huge.init_function = 'tapas_huge_compile';
infos.huge.init_dir = 'huge';
infos.huge.dependencies = [];
infos.huge.diagnose_files = '';
infos.huge.test_function_name = '';

infos.physio.init_dir = strcat('PhysIO',filesep,'code');
infos.physio.init_function = 'tapas_physio_init';
infos.physio.dependencies = [];
infos.physio.diagnose_files = 'tapas_physio_main_create_regressors';
infos.physio.test_function_name = '';

infos = tapas_default_toolbox_info(infos,'rDCM');

Expand All @@ -50,12 +53,14 @@
infos.uniqc.init_function = '';
infos.uniqc.dependencies = [];
infos.uniqc.diagnose_files = 'tapas_uniqc_demo_fmri_qa'; % in subfolder demo/MrSeries
infos.uniqc.test_function_name = '';

%% Auxillary toolboxes:
infos.external.init_function = '';
infos.external.init_function = '';
infos.external.init_dir = 'external';
infos.external.dependencies = '';
infos.external.diagnose_files = '';
infos.external.test_function_name = 'tapas_test_template';

infos = tapas_default_toolbox_info(infos,'tools'); % Want to have that?

Expand All @@ -73,6 +78,6 @@
infos.(fld_name).init_dir = folderName;
infos.(fld_name).dependencies = '';
infos.(fld_name).diagnose_files = '';

infos.(fld_name).test_function_name = '';
end

146 changes: 146 additions & 0 deletions misc/tapas_test.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
function [nTestFailed,nTestTotal] = tapas_test(toolboxes,level)
% TAPAS_TEST Run tests of TAPAS toolboxes
%
% IN
% toolboxes
% Names of toolboxes to test (including their dependencies)-
% If empty, all toolboxes are used.
% level
% Detail of the test (per toolbox).
% 0: Roughly a minute.
% 1: Coffebreak.
% 2: Lunch break.
% 3: Overnight.
%
% OUT
%
%
% This function serves as a wrapper function to run the tests of the TAPAS toolboxes.
%
% See also
%
% (C) 18.07.22, Translational Neuromodeling Unit, UZH & ETH Zürich, Matthias Müller-Schrader

doTestAll = false;

if nargin < 1 || isempty(toolboxes)
toolboxes = {};
doTestAll = true;
else
toolboxes = lower(toolboxes);
if ~iscell(toolboxes)
toolboxes = {toolboxes}; % We want to have it as a cell array afterwards.
end
end

if nargin < 2 || isempty(level)
level = 3;
end

% In the infos struct, we have all information about our toolboxes.

infos = tapas_get_toolbox_infos();
% Coding here is similar to tapas_init_toolboxes
toolbox_names = fieldnames(infos);
nTool = numel(toolbox_names); % All tapas-toolboxes
NTool = numel(toolboxes); % All specified toolboxes
if doTestAll
doTest = ones(size(toolbox_names),'logical');
else
doTest = zeros(size(toolbox_names),'logical');
for iTool = 1:NTool % Run over specified toolboxes
sTool = toolboxes{iTool};
if ~ismember(sTool,toolbox_names)
warning('I do not know the toolbox %s - skipping it.\n',sTool);
continue;
end
doTest(ismember(toolbox_names,sTool)) = true;
dependencies = lower(infos.(sTool).dependencies);
if ~isempty(dependencies)
doTest(ismember(toolbox_names,dependencies)) = true;
end
end
end

% Now run through the tests of the required toolboxes.
testResults = zeros(nTool,2);
for iTool = 1:nTool
if ~doTest(iTool)
continue;
end
toolboxName = toolbox_names{iTool};
testFunctionName = infos.(toolboxName).test_function_name;

str = sprintf('~~~~~~~~~~~~~~~~~~~~~~~~ TESTING <strong>%s</strong> ~',...
upper(toolboxName));
str(end+1:80+17) = '~'; % 17 for <strong></strong>
fprintf(1,'%s\n',str);
if isempty(testFunctionName)
fprintf('Tests not implemented yet.\n')
%fprintf('\tTest for toolbox %s not implemented yet.\n',toolboxName)
continue;
end
hTestFunction = str2func(testFunctionName);

try
[nTestFailed,nTestTotal] = hTestFunction(level);
catch me
warning('Test for toolbox failed with message:\n\t%s',me.message);%#ok
nTestFailed = 1;
nTestTotal = 1;
end
testResults(iTool,1) = nTestFailed;
testResults(iTool,2) = nTestTotal;
fprintf('<strong>Summary</strong> %s: %d out of %d tests failed.\n',...
toolboxName,nTestFailed,...
nTestTotal)
end

nTestFailed = sum(testResults(:,1));
nTestTotal = sum(testResults(:,2));
fprintf(['~~~~~~~~~~~~~~~~~~~~~~~~ <strong>SUMMARY</strong> ~~~~~~~~~~~~~~~~~~~~',...
'~~~~~~~~~~~~~~~~~~~~~~~~~~~\n'])
fprintf('<strong>Summary</strong>: %d of %d tests failed\n',nTestFailed,nTestTotal);

end

function [nTestFailed,nTestTotal] = tapas_test_template(level)
% This minimal working example demonstrates the interface
% for the toolbox-specific test-functions.
%
% Approximate time per level (per toolbox)
% 0: around a minute
% 1: around 5 minutes (a coffee)
% 2: around an hour (time for lunch)
% 3: overnight (time to freakout [deadline])
error('Hallloooo')
if level < 1
nTestTotal = 2;
else
nTestTotal = 3;
end
nTestFailed = 0;
randomNumber = randn(1);
if randomNumber < 0
fprintf('First test failed :(\n')
nTestFailed = nTestFailed + 1;
end

randomNumberUnitInterval = rand();
if randomNumberUnitInterval < 0.5
fprintf('Second test failed :(\n')
nTestFailed = nTestFailed + 1;
end

if level >= 1
pause(300); % To justify the level ;)
randomInteger = randi(10,1);
if randomInteger < 5
fprintf('Third test failed :( \n')
nTestFailed = nTestFailed + 1;
end
end

end


0 comments on commit e9c9423

Please sign in to comment.