Try Heaters out with simple TE and TM MZI circuits (#3) #201
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run YAML verification | |
on: | |
workflow_dispatch: | |
workflow_run: | |
workflows: ["Run Python Files"] | |
types: | |
- completed | |
push: | |
paths: | |
- 'submissions/**.yaml' | |
branches: | |
- '**' | |
pull_request: | |
paths: | |
- 'submissions/**.yaml' | |
branches: | |
- '**' | |
jobs: | |
verification: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout repo content | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
# can also specify python version if needed | |
- name: setup python | |
uses: actions/setup-python@v4 | |
- name: install python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install PyYAML | |
- name: get .yaml files, run verification | |
id: run-script | |
run: | | |
if [ "${{ github.event_name }}" = "pull_request" ]; then | |
# triggered on pull request, get all changed / added files from forked repo | |
export FILES=$(git diff --name-only --diff-filter=ACM FETCH_HEAD | grep -E '\.(yaml|yml)$' | sed 's|^submissions/||') | |
else | |
# triggered push, locate the changed / added .yaml files in the submission folder | |
export FILES=$(git diff --name-status --diff-filter=ACM --relative=submissions ${{ github.event.before }} ${{ github.sha }} submissions | grep -E '\.(yaml|yml)$' | awk '{print $2}') | |
fi | |
IFS=$'\n' | |
# print the names of the files | |
echo "Files for verification; $FILES" | |
files_with_errors="" | |
# run verification on all files | |
for file in $FILES; do | |
echo "Running verification on $file" | |
output=$(python run_yaml_verification.py "submissions/$file") | |
echo $output >> $GITHUB_STEP_SUMMARY | |
# get number of errors | |
#errors_from_output=$(echo "$output" | tail -n 1) | |
#echo "$errors_from_output errors detected for $file" | |
# if file results in verification errors add to string files_with_errors | |
#if [[ "$errors_from_output" -ge 1 ]]; then | |
# files_with_errors+="$file, $errors_from_output errors. " | |
#fi | |
echo "Done verification on $file" | |
done | |
echo "files_with_errors=$files_with_errors" >> $GITHUB_ENV | |
- name: fail if there are errors from verification | |
run: | | |
if [ -z "$files_with_errors" ]; then | |
echo "No errors detected." | |
echo "No errors detected." >> $GITHUB_STEP_SUMMARY | |
else | |
echo "Errors detected: $files_with_errors" | |
echo "Errors detected: $files_with_errors" >> $GITHUB_STEP_SUMMARY | |
exit 1 | |
fi | |