Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic CI to fetch, merge, filter tools and create static pages #34

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bf9d54a
action in main to manually dispatch
paulzierep Nov 3, 2023
467e6bb
update
paulzierep Nov 3, 2023
07961c9
update
paulzierep Nov 3, 2023
e7626b6
update
paulzierep Nov 3, 2023
48d9af2
update
paulzierep Nov 3, 2023
27b180c
All tools bot
invalid-email-address Nov 3, 2023
98d0fae
full wf
paulzierep Nov 3, 2023
49f4805
update
paulzierep Nov 3, 2023
2213666
filter community tool bot
paulzierep Nov 3, 2023
ab56119
filter communities bot
invalid-email-address Nov 3, 2023
e18845f
test flter
paulzierep Nov 3, 2023
10a4660
filter communities bot
invalid-email-address Nov 3, 2023
9e890f9
trigger pages only when new results are created
paulzierep Nov 3, 2023
0f523f9
Update .github/workflows/static.yml
paulzierep Nov 22, 2023
071f01b
fetch tools stepwise with CI
paulzierep Nov 23, 2023
e2586df
update CI
paulzierep Nov 28, 2023
7cf6523
updat CI
paulzierep Nov 28, 2023
35b3ec8
update CI
paulzierep Nov 28, 2023
42581d4
update CI
paulzierep Nov 28, 2023
15a1a40
linting
paulzierep Nov 28, 2023
5636b03
update CI and get more verbose tool logs
paulzierep Dec 7, 2023
4823d23
add a test case to check what up with the CI
paulzierep Dec 7, 2023
fa063ca
allow to run the test ever
paulzierep Dec 7, 2023
68ff222
try test with other api key
paulzierep Dec 7, 2023
6e5e119
next try
paulzierep Dec 7, 2023
1dae981
as secrets
paulzierep Dec 7, 2023
d97005d
fetch all tools bot
invalid-email-address Dec 7, 2023
668005c
merge test
paulzierep Dec 7, 2023
3b2a2ad
cat in CI
paulzierep Dec 7, 2023
931936e
CI all tools
paulzierep Dec 7, 2023
26c7e1e
CI test
paulzierep Dec 7, 2023
afbe5db
force push
paulzierep Dec 7, 2023
5ae46fc
fetch all tools bot - step merge
invalid-email-address Dec 7, 2023
8850334
test git merge
paulzierep Dec 8, 2023
a87e711
more tests
paulzierep Dec 8, 2023
15a4ea6
cover staged change as well
paulzierep Dec 8, 2023
f2fab68
fetch all tools bot - step fetch
invalid-email-address Dec 8, 2023
380704f
CI test
paulzierep Dec 8, 2023
0955e59
fetch all tools bot - step fetch
invalid-email-address Dec 8, 2023
8d4d487
update fetch and filter CI
paulzierep Dec 8, 2023
0392d76
rm results - let the CI do it !
paulzierep Dec 8, 2023
bf50bb9
Merge branch 'main' into fetch-tools-CI
paulzierep Dec 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/fetch_all_tools.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Fetch all tools

on:
workflow_dispatch:
schedule:
#Every Sunday at 8:00 am
- cron: "0 8 * * 0"

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "tools"
cancel-in-progress: false

permissions:
contents: write

jobs:
fetch-all-tools-stepwise:
runs-on: ubuntu-20.04
environment: fetch-tools
name: Fetch all tool stepwise
strategy:
matrix:
python-version: [3.8]
subset:
- repositories01.list
- repositories02.list
- repositories03.list
- repositories04.list
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Comment on lines +32 to +33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5

with:
python-version: ${{ matrix.python-version }}
- name: Install requirement
run: python -m pip install -r requirements.txt
- name: Run script
run: |
export GITHUB_API_KEY=${{ secrets.GH_API_TOKEN }}
bash ./bin/extract_all_tools_stepwise.sh "${{ matrix.subset }}"
- name: Commit all tools
# add or commit any changes in results if there was a change, merge with main and push as bot
run: |
git config user.name github-actions
git config user.email [email protected]
git add results
git status
git diff --quiet && git diff --staged --quiet || (git commit -m "fetch all tools bot - step fetch")
git pull -s recursive -X ours
git push

fetch-all-tools-merge:
runs-on: ubuntu-20.04
needs: fetch-all-tools-stepwise
name: Fetch all tools merge
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Comment on lines +58 to +59
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5

- name: Install requirement
run: python -m pip install -r requirements.txt
- name: Run script
run: |
cat results/repositories*.list_tools.tsv > results/all_tools.tsv
bash ./bin/extract_all_tools_downstream.sh
- name: Commit all tools
# add or commit any changes in results if there was a change, merge with main and push as bot
run: |
git config user.name github-actions
git config user.email [email protected]
git add results
git status
git diff --quiet && git diff --staged --quiet || (git commit -m "fetch all tools bot - step merge")
git pull -s recursive -X ours
git push
38 changes: 38 additions & 0 deletions .github/workflows/filter_communities.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Filter community tools

on:
workflow_dispatch:

# the workflow it triggered when all_tools_tsv is changed
push:
paths:
- 'results/all_tools_tsv'
branches: ["main"]

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "filter"
cancel-in-progress: false

permissions:
contents: write

jobs:
filter-all-tools:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Comment on lines +25 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5

- name: Install requirement
run: python -m pip install -r requirements.txt
- name: Run script
run: |
bash ./bin/get_community_tools.sh
- name: Commit results
# commit the new filtered data, only if stuff was changed
run: |
git config user.name github-actions
git config user.email [email protected]
git diff --quiet || (git add results && git commit -m "filter communities bot")
git push
66 changes: 66 additions & 0 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Run tests

on:
workflow_dispatch:

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
# concurrency:
# group: "tools"
# cancel-in-progress: false

permissions:
contents: write

jobs:
fetch-all-tools-stepwise:
runs-on: ubuntu-20.04
environment: fetch-tools
name: Fetch all tool stepwise
strategy:
matrix:
python-version: [3.8]
subset:
- repositories02.list
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Comment on lines +26 to +27
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5

with:
python-version: ${{ matrix.python-version }}
- name: Install requirement
run: python -m pip install -r requirements.txt
- name: Run script
# run: bash bin/extract_all_tools.sh
run: |
export GITHUB_API_KEY=${{ secrets.GH_API_TOKEN }}
bash ./bin/extract_all_tools_test.sh "${{ matrix.subset }}"
- name: Commit all tools
# add or commit any changes in results if there was a change, merge with main and push as bot
run: |
git config user.name github-actions
git config user.email [email protected]
git add results
git status
git diff --quiet && git diff --staged --quiet || (git commit -m "fetch all tools bot - step fetch")
git pull -s recursive -X ours
git push

# fetch-all-tools-merge:
# runs-on: ubuntu-20.04
# needs: fetch-all-tools-stepwise
# name: Fetch all tools merge
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v4
Comment on lines +53 to +54
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v4
# - uses: actions/checkout@v4
# - uses: actions/setup-python@v5

# - name: Install requirement
# run: python -m pip install -r requirements.txt
# - name: Run script
# run: |
# cat results/repositories*.list_tools.tsv > results/all_tools.tsv
# bash ./bin/extract_all_tools_downstream.sh
# - name: Commit all tools
# run: |
# git config user.name github-actions
# git config user.email [email protected]
# git diff --quiet || (git add results && git commit -m "fetch all tools bot - step merge")
# git push
5 changes: 4 additions & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
# the workflow is triggered only when results are changed
push:
paths:
- 'results'
branches: ["main"]


# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand Down
Empty file modified bin/extract_all_tools.sh
100644 → 100755
Empty file.
8 changes: 8 additions & 0 deletions bin/extract_all_tools_downstream.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

mkdir -p 'results/'

python bin/create_interactive_table.py \
--table "results/all_tools.tsv" \
--template "data/interactive_table_template.html" \
--output "results/index.html"
12 changes: 12 additions & 0 deletions bin/extract_all_tools_stepwise.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

mkdir -p 'results/'

output="results/${1}_tools.tsv"

python bin/extract_galaxy_tools.py \
extractools \
--api $GITHUB_API_KEY \
--all_tools $output \
--planemorepository $1

13 changes: 13 additions & 0 deletions bin/extract_all_tools_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

mkdir -p 'results/'

output="results/${1}_tools.tsv"

python bin/extract_galaxy_tools.py \
extractools \
--api $GITHUB_API_KEY \
--all_tools $output \
--planemorepository $1 \
--test

48 changes: 38 additions & 10 deletions bin/extract_galaxy_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,36 @@ def get_string_content(cf: ContentFile) -> str:
return base64.b64decode(cf.content).decode("utf-8")


def get_tool_github_repositories(g: Github) -> List[str]:
def get_tool_github_repositories(g: Github, RepoSelection: Optional[str], run_test: bool) -> List[str]:
"""
Get list of tool GitHub repositories to parse

:param g: GitHub instance
:param RepoSelection: The selection to use from the repository (needed to split the process for CI jobs)
:run_test: for CI testing only use one repository
"""

if run_test:
return ["https://github.com/TGAC/earlham-galaxytools"]

repo = g.get_user("galaxyproject").get_repo("planemo-monitor")
repo_list: List[str] = []
for i in range(1, 5):
repo_f = repo.get_contents(f"repositories0{i}.list")
repo_l = get_string_content(repo_f).rstrip()
repo_list.extend(repo_l.split("\n"))
repo_selection = f"repositories0{i}.list"
if RepoSelection: # only get these repositories
if RepoSelection == repo_selection:
repo_f = repo.get_contents(repo_selection)
repo_l = get_string_content(repo_f).rstrip()
repo_list.extend(repo_l.split("\n"))
else:
repo_f = repo.get_contents(repo_selection)
repo_l = get_string_content(repo_f).rstrip()
repo_list.extend(repo_l.split("\n"))

print("Parsing repositories from:")
for repo in repo_list:
print("\t", repo)

return repo_list


Expand Down Expand Up @@ -475,11 +493,20 @@ def filter_tools(
# Extract tools
extractools = subparser.add_parser("extractools", help="Extract tools")
extractools.add_argument("--api", "-a", required=True, help="GitHub access token")

extractools.add_argument("--all_tools", "-o", required=True, help="Filepath to TSV with all extracted tools")
extractools.add_argument(
"--all_tools",
"-o",
required=True,
help="Filepath to TSV with all extracted tools",
"--planemorepository", "-pr", required=False, help="Repository list to use from the planemo-monitor repository"
)

extractools.add_argument(
"--test",
"-t",
action="store_true",
default=False,
required=False,
help="Run a small test case using only the repository: https://github.com/TGAC/earlham-galaxytools",

)

# Filter tools
Expand Down Expand Up @@ -517,12 +544,13 @@ def filter_tools(
# connect to GitHub
g = Github(args.api)
# get list of GitHub repositories to parse
repo_list = get_tool_github_repositories(g)

repo_list = get_tool_github_repositories(g, args.planemorepository, args.test)

# parse tools in GitHub repositories to extract metada, filter by TS categories and export to output file
tools: List[Dict] = []
for r in repo_list:
print(r)
print("Parsing tools from:", (r))
if "github" not in r:
continue
try:
Expand Down
Empty file modified bin/get_community_tools.sh
100644 → 100755
Empty file.
Loading
Loading