Skip to content

On Pull Request

On Pull Request #78

Workflow file for this run

name: On Pull Request
on:
workflow_dispatch:
#pull_request:
#paths:
# - '**/*.gpml'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: false # to allow multiple runs to queue up rather than clobber
jobs:
# Retrieves GPML file and PR number associated with incoming Pull Request and creates
# global variables that can accessed by subsequent jobs:
# * pr-number = the unique number that identifies a Pull Request
# * add-modified = a GPML file that is being added or modified in the wikipathways database
# * deleted = a GPML file that is being deleted from the wikipathways database
get-gpml-pr:
runs-on: ubuntu-latest
outputs:
pr-number: ${{ steps.changes.outputs.pr-number }}
added-modified: ${{ steps.changes.outputs.added-modified }}
deleted: ${{ steps.changes.outputs.deleted }}
steps:
# Make sure we have some code to diff.
- name: Checkout repository
uses: actions/checkout@v4
- name: Get PR and GPML
id: changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} #only need to support TESTING via GH API calls
run: |
echo "GPML files were changed in pull request ${{ github.event.before }} -> ${{ github.event.after }}"
#echo "pr-number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
echo "pr-number=10" >> $GITHUB_OUTPUT #TESTING
#echo "added-modified=$(git diff --name-only --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} | grep .gpml$ | xargs)" >> $GITHUB_OUTPUT
echo "added-modified=$(gh pr view 10 --json files --jq '.files.[].path' | grep '.gpml$')" >> $GITHUB_OUTPUT #TESTING
if git diff --name-only --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} | grep .gpml$; then
echo 'added or modified:'
git diff --name-only --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} | grep .gpml$
fi
echo "deleted=$(git diff --name-only --diff-filter=D ${{ github.event.before }} ${{ github.event.after }} | grep .gpml$ | xargs)" >> $GITHUB_OUTPUT
if git diff --name-only --diff-filter=D ${{ github.event.before }} ${{ github.event.after }} | grep .gpml$; then
echo 'deleted:'
git diff --name-only --diff-filter=D ${{ github.event.before }} ${{ github.event.after }} | grep .gpml$
fi
get-branch:
needs: [get-gpml-pr]
if: ${{needs.get-gpml-pr.outputs.added-modified}}
runs-on: ubuntu-latest
outputs:
branch-name: ${{ steps.changes.outputs.branch-name }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: refs/pull/${{needs.get-gpml-pr.outputs.pr-number}}/head
- name: Get branch name for future pushes
id: changes
run: |
BRANCH_NAME=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{needs.get-gpml-pr.outputs.pr-number}} \
| jq -r .head.ref)
echo "branch-name=$BRANCH_NAME"
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
if ! git ls-remote --heads origin $BRANCH_NAME; then
git push origin HEAD:refs/heads/$BRANCH_NAME
fi
check_gpml:
needs: [get-gpml-pr,get-branch]
if: ${{needs.get-gpml-pr.outputs.added-modified}}
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: refs/pull/${{needs.get-gpml-pr.outputs.pr-number}}/head
- name: Install XML processing tools
run: sudo apt-get install -y libxml2-utils
- name: Check GPML file
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
GPML_FILE=${{needs.get-gpml-pr.outputs.added-modified}}
echo "Found .gpml file: $GPML_FILE"
wpid="$(basename ""$GPML_FILE"" | sed 's/.gpml//')"
org="$(xmllint --xpath 'string(//*[local-name()="Pathway"]/@Organism)' "$GPML_FILE")"
name="$(xmllint --xpath 'string(//*[local-name()="Pathway"]/@Name)' "$GPML_FILE")"
desc="$(xmllint --xpath 'string(//*[local-name()="Comment" and @Source="WikiPathways-description"])' "$GPML_FILE")"
# Start PR description
NEW_DESCRIPTION="
## Pathway Information
**WPID**: $wpid
**TITLE**: $name
**ORGANISM**: $org
**DESCRIPTION**: $desc
---
"
PR_NUMBER=${{needs.get-gpml-pr.outputs.pr-number}}
gh pr edit $PR_NUMBER --body "$NEW_DESCRIPTION"
metadata:
needs: [get-gpml-pr,get-branch,check_gpml]
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: refs/pull/${{needs.get-gpml-pr.outputs.pr-number}}/head
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Cache meta-data-action with dependencies
uses: actions/cache@v3
id: cacheMetaJar
with:
path: ./meta-data-action-1.1.2-jar-with-dependencies.jar
key: cached-meta-data-action-${{ hashFiles('meta-data-action-1.1.2-jar-with-dependencies.jar') }}
restore-keys: |
cached-meta-data-action-${{ hashFiles('meta-data-action-1.1.2-jar-with-dependencies.jar') }}
cached-meta-data-action-
- name: Install deps
run: |
echo "Refreshing cached-meta-data-action"
if [ ! -e ./meta-data-action-1.1.2-jar-with-dependencies.jar ]; then
wget -O meta-data-action-1.1.2-jar-with-dependencies.jar https://github.com/wikipathways/meta-data-action/releases/download/v1.1.2/meta-data-action-1.1.2-jar-with-dependencies.jar
fi
- name: Cache and install dependencies
uses: actions/cache@v3
id: cache
with:
path: ${{ github.workspace }}/Hs_Derby_Ensembl_108.bridge
key: ${{ runner.os }}-java-Hs_Derby_Ensembl_108
restore-keys: |
${{ runner.os }}-java-Hs_Derby_Ensembl_108
${{ runner.os }}-java-Hs_Derby_Ensembl_
- if: steps.cache.outputs.cache-hit != 'true'
name: Install deps
run: |
cd "${{ github.workspace }}"
if [ ! -e ./Hs_Derby_Ensembl_108.bridge ]; then
wget -O Hs_Derby_Ensembl_108.bridge https://zenodo.org/record/7781913/files/Hs_Derby_Ensembl_108.bridge?download=1
fi
- name: Generate gdb.config, fileNames.config, and fileDownloads.config
run: |
for f in ${{needs.changed-gpmls.outputs.added-modified}}; do
scripts/meta-data-action/configGenerator.sh $f
done
- name: Cache all bridge files
uses: actions/cache@v3
id: cacheAllBridge
with:
path: |
./metabolites*.bridge
./Ag*.bridge
./An*.bridge
./At*.bridge
./Bs*.bridge
./Bt*.bridge
./Ce*.bridge
./Cf*.bridge
./Ci*.bridge
./Dr*.bridge
./Da*.bridge
./Dp*.bridge
./Dm*.bridge
./Ec*.bridge
./Gg*.bridge
./Fg*.bridge
./Gm*.bridge
./Hs*.bridge
./Hv*.bridge
./Ml*.bridge
./Mm*.bridge
./Mx*.bridge
./Oa*.bridge
./Ova*.bridge
./Oi*.bridge
./Oj*.bridge
./Pi*.bridge
./Pt*.bridge
./Qc*.bridge
./Rn*.bridge
./Sc*.bridge
./Sl*.bridge
./Ss*.bridge
./Vv*.bridge
./Xt*.bridge
./Zm*.bridge
key: cached-bridge-files
restore-keys: |
cached-bridge-files
- if: steps.cacheAllBridge.outputs.cache-hit != 'true'
name: Install all bridge files
run: |
echo "Cache not found: cached-bridge-files"
declare -a OrganismNames=("Metabolites" "Anopheles gambiae" "Aspergillus niger" "Arabidopsis thaliana" "Bacillus subtilis" "Bos taurus" "Caenorhabditis elegans" "Canis familiaris" "Ciona intestinalis" "Danio rerio" "Daphnia magna" "Daphnia pulex" "Drosophila melanogaster" "Escherichia coli" "Gallus gallus" "Fusarium graminearum" "Glycine max" "Homo sapiens" "Hordeum vulgare" "Macaca mulatta" "Mus musculus" "Mycobacterium tuberculosis" "Ornithorhynchus anatinus" "Ovis aries" "Oryza indica" "Oryza japonica" "Populus trichocarpa" "Pan troglodytes" "Equus caballus" "Rattus norvegicus" "Saccharomyces cerevisiae" "Solanum lycopersicum" "Sus scrofa" "Vitis vinifera" "Xenopus tropicalis" "Zea mays")
for org in "${OrganismNames[@]}"; do
echo "generating configuration files for "$org""
scripts/meta-data-action/configGenerator.sh "$org"
echo "installing bridgedb files for "$org""
scripts/meta-data-action/installDependencies.sh "$org"
done
- name: Generate configs, install bridgeDb, generate info and datanode files
run: |
chmod 777 meta-data-action-1.1.2-jar-with-dependencies.jar
f=${{ needs.get-gpml-pr.outputs.added-modified }}
echo "value of f "$f""
org="$(sed -n '/<Pathway /s/.*Organism=\(.*\)[^\n]*/\1/p' $f | tr -d '"' | tr -d '>' | tr -d '\r')"
echo "generating configuration files for "$org""
scripts/meta-data-action/configGenerator.sh "$org"
wpid="$(basename ""$f"" | sed 's/.gpml//')"
cat gdb.config
echo "generating info and datanode files for $wpid, organism "$org""
java -jar meta-data-action-1.1.2-jar-with-dependencies.jar local "$f" $(date --utc +%F) gdb.config "$org"
- name: Commit info and datanode files to PR branch
run: |
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github.com'
git add pathways/WP*/WP*.{json,tsv}
if git diff --exit-code --staged; then
echo "No changes"
else
echo "TODO: Save the new files"
git commit -m 'Update metadata files'
# NOT WORKING DUE TO BRANCH NOT EXISTING ON MAIN YET
#git pull origin ${{needs.get-branch.outputs.branch-name}} --rebase
#git push origin HEAD:refs/heads/${{needs.get-branch.outputs.branch-name}}
fi
- name: Report on meta-data-action
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Verify generated files
infojson=$(find . -path "./pathways/WP*/WP*info.json" -print -quit)
dntsv=$(find . -path "./pathways/WP*/WP*datanodes.tsv" -print -quit)
refstsv=$(find . -path "./pathways/WP*/WP*refs.tsv" -print -quit)
# Update PR description
PR_NUMBER=${{needs.get-gpml-pr.outputs.pr-number}}
CURRENT_DESCRIPTION=$(gh pr view $PR_NUMBER --json body -q ".body")
NEW_DESCRIPTION="$CURRENT_DESCRIPTION
## Generate Metadata Files
"
if [[ -n $infojson ]]; then
NEW_DESCRIPTION="$NEW_DESCRIPTION
- [x] info.json generated
"
else
NEW_DESCRIPTION="$NEW_DESCRIPTION
- [] info.json generated
"
fi
if [[ -n $dntsv ]]; then
NEW_DESCRIPTION="$NEW_DESCRIPTION
- [x] datanodes.tsv generated
"
else
NEW_DESCRIPTION="$NEW_DESCRIPTION
- [] datanodes.tsv generated
"
fi
if [[ -n $refstsv ]]; then
NEW_DESCRIPTION="$NEW_DESCRIPTION
- [x] refs.tsv generated
"
else
NEW_DESCRIPTION="$NEW_DESCRIPTION
- [] refs.tsv generated
"
fi
gh pr edit $PR_NUMBER --body "$NEW_DESCRIPTION"
pubmed:
needs: [get-gpml-pr,get-branch,metadata]
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: refs/pull/${{needs.get-gpml-pr.outputs.pr-number}}/head
- name: Run generate-references
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "TODO: Run generate-references and attach output TSV to PR"
# Update PR description
PR_NUMBER=${{needs.get-gpml-pr.outputs.pr-number}}
CURRENT_DESCRIPTION=$(gh pr view $PR_NUMBER --json body -q ".body")
NEW_DESCRIPTION="$CURRENT_DESCRIPTION
- [x] references.tsv generated
"
gh pr edit $PR_NUMBER --body "$NEW_DESCRIPTION"
frontmatter:
needs: [get-gpml-pr,get-branch,pubmed]
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: refs/pull/${{needs.get-gpml-pr.outputs.pr-number}}/head
- name: Run create_pathway_frontmatter.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "TODO: Run create_pathway_frontmatter.py and attach output MD to PR"
# Update PR description
PR_NUMBER=${{needs.get-gpml-pr.outputs.pr-number}}
CURRENT_DESCRIPTION=$(gh pr view $PR_NUMBER --json body -q ".body")
NEW_DESCRIPTION="$CURRENT_DESCRIPTION
- [x] .md generated
"
gh pr edit $PR_NUMBER --body "$NEW_DESCRIPTION"
json-svg:
needs: [get-gpml-pr,get-branch,frontmatter]
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: refs/pull/${{needs.get-gpml-pr.outputs.pr-number}}/head
- name: Run generate-svgs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "TODO: Run generate-svgs and attach output JSON, SVG and PNG to PR"
# Update PR description
PR_NUMBER=${{needs.get-gpml-pr.outputs.pr-number}}
CURRENT_DESCRIPTION=$(gh pr view $PR_NUMBER --json body -q ".body")
NEW_DESCRIPTION="$CURRENT_DESCRIPTION
- [x] .json generated
- [x] .svg generated
- [x] .png generated
*TODO: insert PNG here*
"
gh pr edit $PR_NUMBER --body "$NEW_DESCRIPTION"
testing:
needs: [get-gpml-pr,get-branch,json-svg]
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: refs/pull/${{needs.get-gpml-pr.outputs.pr-number}}/head
- name: Perform automatic test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# TODO: perform testing
# Update PR description
PR_NUMBER=${{needs.get-gpml-pr.outputs.pr-number}}
CURRENT_DESCRIPTION=$(gh pr view $PR_NUMBER --json body -q ".body")
NEW_DESCRIPTION="$CURRENT_DESCRIPTION
---
## Automated Testing
*As table*
| # | Test name | Link | Notes | Result |
|---|---|---|---|---|
| 1 | Test one | | | \$\${\color{green}PASS}\$\$ |
| 2 | Test two | | | \$\${\color{red}FAIL}\$\$ |
| 3 | Test three | | | \$\${\color{green}PASS}\$\$ |
*As checklist*
- [ ] Interactions are connected
- [ ] Datanodes are annotated with database references
- [ ] Decription, consisting of 2-3 sentence overview of processes described in the pathway
- [ ] At least one literature reference
- [ ] At least one pathway ontology term
- [ ] Pathway title conforms to the [guidelines](https://github.com/wikipathways/wikipathways-faq/discussions/24)
---
"
gh pr edit $PR_NUMBER --body "$NEW_DESCRIPTION"