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

add workflow to update overview of available software #189

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
55 changes: 55 additions & 0 deletions .github/workflows/update_available_software.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Update overview of available software in EESSI
on:
- workflow_dispatch
jobs:
update_available_software:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4

- name: set up Python
uses: actions/setup-python@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
python-version: '3.10'
architecture: x64

- name: Mount EESSI
uses: eessi/github-action-eessi@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
eessi_stack_version: '2023.06'

- name: update overview of available software
id: update_available_software
run: |
cd scripts/available_software

# install required Python packages in virtual environment
python -m venv venv
. venv/bin/activate
pip install -r requirements.txt

python available_software.py
git status

# determine whether pull request should be opened:
# if JSON files in docs/available_software/data have been updated, then a PR should be opened
json_data_changed=$((git diff --exit-code ../../docs/available_software/data > /dev/null && echo 'no') || echo 'yes')
if [[ ${json_data_changed} == "yes" ]]; then
echo "JSON files in docs/available_software/data have been changed, PR should be opened"
else
echo "JSON files in docs/available_software/data have not been changed, no need to open PR"
fi
echo "json_data_changed=${json_data_changed}" >> $GITHUB_OUTPUT

- name: create pull request
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
if: steps.update_available_software.outputs.json_data_changed == 'yes'
with:
add-paths: docs/available_software
branch: update-software-overview
branch-suffix: timestamp
commit-message: update overview of available software
title: update overview of available software
body: ''
token: ${{ secrets.EESSIBOT_GITHUB_TOKEN }}
push-to-fork: EESSIbot/docs
7 changes: 1 addition & 6 deletions scripts/available_software/available_software.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import subprocess
import sys
import time
from pathlib import Path
from typing import Union, Tuple
import numpy as np
from mdutils.mdutils import MdUtils
Expand All @@ -35,11 +34,7 @@

def main():
os.environ["SHELL"] = "/bin/bash"
current_dir = Path(__file__).resolve()
project_name = 'docs'
root_dir = next(
p for p in current_dir.parents if p.parts[-1] == project_name
)
root_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this because the available_software.py script was failing in a checkout my fork, because the top-level directory there was EESSI-docs rather than docs.

I don't see the need to use pathlib here, it makes the code a whole lot more messy and hard to understand, imho

path_data_dir = os.path.join(root_dir, "docs/available_software/data")

# Generate the JSON overviews
Expand Down
Loading