Skip to content

Commit

Permalink
Maintainance PR (#527)
Browse files Browse the repository at this point in the history
* feat: fixed the pydata-sphinx-theme version dependency

* ix: language render and annotations

* feat: added design updates to fix the UI

* fix: multi lingual support

* maintainance PR

* cache builds to reduce build time

* cache builds to reduce build time

* fix cleanPR
  • Loading branch information
henilp105 authored Feb 21, 2025
1 parent 7cedeb3 commit 4895356
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
python-version: "3.10"

- name: Setup Fortran compiler
uses: fortran-lang/[email protected].1
uses: fortran-lang/[email protected].3
id: setup-fortran
with:
compiler: gcc
Expand Down
29 changes: 18 additions & 11 deletions .github/workflows/closePR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,27 @@ jobs:
- name: Iterate and Check PRs
id: pr_check
run: |
pr_folders=($(cd pr && ls -d */))
# Get the list of PR folders inside 'pr/' (e.g., pr/123, pr/456)
pr_folders=($(find pr -mindepth 1 -maxdepth 1 -type d -printf "%f\n"))
closed_pr=()
for pr_folder in "${pr_folders[@]}"; do
pr_status=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-X GET "https://api.github.com/repos/${{ github.repository }}/pulls/${pr_folder::-1}" \
| jq -r '.state')
echo "PR ${pr_folder::-1} is $pr_status"
if [ "$pr_status" != "open" ]; then
rm -rf "pr/${pr_folder::-1}"
closed_pr+=("${pr_folder::-1}")
echo "Removed folder pr/${pr_folder::-1} for closed PR ${pr_folder::-1}"
fi
# Fetch PR status from GitHub API
pr_status=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-X GET "https://api.github.com/repos/${{ github.repository }}/pulls/$pr_folder" | jq -r '.state')
echo "PR $pr_folder is $pr_status"
# Remove the folder if PR is closed
if [[ "$pr_status" != "open" ]]; then
rm -rf "pr/$pr_folder"
closed_pr+=("$pr_folder")
echo "Removed folder pr/$pr_folder for closed PR $pr_folder"
fi
done
echo "${closed_pr[*]}" >> $GITHUB_STATE
# Store closed PRs in GITHUB_STATE for later use
echo "${closed_pr[*]}" >> "$GITHUB_STATE"
- name: Commit and push to gh-pages
uses: EndBug/[email protected]
Expand Down
52 changes: 34 additions & 18 deletions extensions/fortran_playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,54 @@
from sphinx.util._lines import parse_line_num_spec
from docutils import nodes
import subprocess
import hashlib
import os


comp_error = ["<ERROR>","Error","app/main.f90","<h1>Bad Request</h1>"]


class PlayCodeBlock(CodeBlock):

def compile_and_execute_fortran(self,fortran_code, filename="code.f90"):
def compile_and_execute_fortran(self,fortran_code):
code_hash = hashlib.md5(fortran_code.encode('utf-8')).hexdigest()
cache_filename = f"build/fortran_output_{code_hash}.txt"
filename=f"build/code_{code_hash}.f90"

# Check if the output is already cached
if os.path.exists(cache_filename):
with open(cache_filename, "r") as f:
return f.read()

with open(filename, "w") as f:
f.write(fortran_code)

compile_command = ["gfortran", filename]
compile_command = ["gfortran", filename, "-o", f"./build/{code_hash}.out"]
compile_result = subprocess.run(compile_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

if compile_result.returncode == 0:
print("Compilation successful!")
with open(cache_filename, "w") as f:

execute_command = ["./a.out"]
execute_result = subprocess.run(execute_command, input="", stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)

if execute_result.returncode == 0:
print("Execution successful!")
print(execute_result.stdout)
return execute_result.stdout
if compile_result.returncode == 0:
print("Compilation successful!")

execute_command = [f"./build/{code_hash}.out"]
execute_result = subprocess.run(execute_command, input="", stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)

if execute_result.returncode == 0:
print("Execution successful!")
print(execute_result.stdout)
f.write(str(execute_result.stdout))
return execute_result.stdout
else:
print("Execution failed.")
print(execute_result.stderr)
f.write(str(execute_result.stderr))
return execute_result.stderr
else:
print("Execution failed.")
print(execute_result.stderr)
return execute_result.stderr
else:
print("Compilation failed.")
print(compile_result.stderr)
return compile_result.stderr
print("Compilation failed.")
print(compile_result.stderr)
f.write(str(compile_result.stderr))
return compile_result.stderr

def run(self):
document = self.state.document
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Sphinx==8.1.3
ablog==0.11.11
ablog==0.11.12
pydata-sphinx-theme==0.16.1
myst-parser==4.0.0
sphinx_design==0.6.1
sphinx_copybutton==0.5.2
sphinx-jinja==2.0.2
jinja2==3.1.4
jinja2==3.1.5
requests==2.32.3
black==24.10.0
black==25.1.0
pylint==3.3.4
pre-commit==4.0.1
pre-commit==4.1.0
sphinx-sitemap==2.6.0
sphinx-favicon==1.0.1

0 comments on commit 4895356

Please sign in to comment.