Component Library Configuration Template + Component Library Tests #9
Workflow file for this run
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 Xircuits Workflows Test | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: "*" | |
jobs: | |
build-and-run: | |
runs-on: ubuntu-latest | |
env: | |
EXCLUDED_XIRCIRCUITS: "path/to/excluded1.xircuits path/to/excluded2.xircuits" | |
# Uncomment the following line and specify paths to exclude additional .xircuits files | |
# EXCLUDED_XIRCIRCUITS: "path/to/excluded1.xircuits path/to/excluded2.xircuits path/to/another_excluded.xircuits" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set COMPONENT_LIBRARY_PATH | |
run: | | |
REPO_NAME="${GITHUB_REPOSITORY##*/}" | |
COMPONENT_LIBRARY_PATH=$(echo "xai_components/xai_${REPO_NAME}" | sed 's/-/_/g') | |
echo "COMPONENT_LIBRARY_PATH=$COMPONENT_LIBRARY_PATH" >> $GITHUB_ENV | |
- name: Install xircuits | |
run: pip install xircuits | |
- name: List xircuits | |
run: xircuits list | |
- name: Clone Repository | |
run: git clone https://github.com/${{ github.repository }} ${{ env.COMPONENT_LIBRARY_PATH }} | |
- name: Process .xircuits Files | |
run: | | |
cd $COMPONENT_LIBRARY_PATH | |
LOG_FILE="${GITHUB_WORKSPACE}/workflow_logs.txt" | |
echo "Looking for .xircuits files in $COMPONENT_LIBRARY_PATH" | tee -a $LOG_FILE | |
FILES=$(find . -name "*.xircuits") | |
if [ -z "$FILES" ]; then | |
echo "No .xircuits files found." | tee -a $LOG_FILE | |
else | |
for file in $FILES; do | |
if [[ $EXCLUDED_XIRCIRCUITS != *"$file"* ]]; then | |
echo "Processing $file..." | tee -a $LOG_FILE | |
xircuits compile $file 2>&1 | tee -a $LOG_FILE | |
python "${file%.*}.py" 2>&1 | tee -a $LOG_FILE | |
if [ $? -ne 0 ]; then | |
echo "Error: Workflow $file failed" | tee -a $LOG_FILE | |
exit 1 | |
fi | |
echo "$file processed successfully" | tee -a $LOG_FILE | |
else | |
echo "Skipping excluded file $file" | tee -a $LOG_FILE | |
fi | |
done | |
fi | |
echo "Workflow processing completed" | tee -a $LOG_FILE | |
- name: Upload log file | |
uses: actions/upload-artifact@v3 | |
with: | |
name: workflow-logs | |
path: ${{ github.workspace }}/workflow_logs.txt |