Check the output of demos on the master and dev branches #219
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: Check the output of demos on the master and dev branches | |
on: | |
schedule: | |
- cron: '0 0 * * 0' | |
workflow_dispatch: | |
jobs: | |
build-dev: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
- uses: actions/checkout@v2 | |
with: | |
ref: dev | |
- name: Run Rigetti Quilc | |
run: docker run --rm -d -p 5555:5555 rigetti/quilc -R | |
- name: Run Rigetti QVM | |
run: docker run --rm -d -p 5000:5000 rigetti/qvm -S | |
- name: Set up Python Version | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Setup Python Environment | |
id: venv | |
run: | | |
if [ ! -d "venv" ]; then python3 -m venv venv; fi | |
echo "location=${{ github.workspace }}/venv" >> $GITHUB_OUTPUT | |
echo "${{ github.workspace }}/venv/bin" >> $GITHUB_PATH | |
- name: Install Poetry | |
id: poetry | |
env: | |
POETRY_HOME: /tmp/poetry | |
run: | | |
curl -sSL https://install.python-poetry.org -o install-poetry.py | |
python3 install-poetry.py --version 1.7.1 | |
$POETRY_HOME/bin/poetry config virtualenvs.create "false" | |
$POETRY_HOME/bin/poetry config virtualenvs.in-project "true" | |
$POETRY_HOME/bin/poetry --version | |
echo "bin=${{ env.POETRY_HOME }}/bin/poetry" >> $GITHUB_OUTPUT | |
- name: Install Python Dependencies | |
run: | | |
source ${{ steps.venv.outputs.location }}/bin/activate | |
make POETRY_BIN="${{ steps.poetry.outputs.bin }}" UPGRADE_PL=1 environment | |
# Adding this install outside of poetry as the dependencies conflict with existing other packages. | |
# TODO: This needs to be revisited. | |
${{ steps.venv.outputs.location }}/bin/python3 -m pip install --no-deps mitiq==0.25.0 | |
- name: Build tutorials | |
run: | | |
make download | |
make html | |
zip -r /tmp/qml_demos.zip demos | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: built-website-dev | |
path: | | |
/tmp/qml_demos.zip | |
_build/html | |
build-master: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
- uses: actions/checkout@v2 | |
with: | |
ref: master | |
- name: Run Rigetti Quilc | |
run: docker run --rm -d -p 5555:5555 rigetti/quilc -R | |
- name: Run Rigetti QVM | |
run: docker run --rm -d -p 5000:5000 rigetti/qvm -S | |
- name: Set up Python Version | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Setup Python Environment | |
id: venv | |
run: | | |
if [ ! -d "venv" ]; then python3 -m venv venv; fi | |
echo "location=${{ github.workspace }}/venv" >> $GITHUB_OUTPUT | |
echo "${{ github.workspace }}/venv/bin" >> $GITHUB_PATH | |
- name: Install Poetry | |
id: poetry | |
env: | |
POETRY_HOME: /tmp/poetry | |
run: | | |
curl -sSL https://install.python-poetry.org -o install-poetry.py | |
python3 install-poetry.py --version 1.7.1 | |
$POETRY_HOME/bin/poetry config virtualenvs.create "false" | |
$POETRY_HOME/bin/poetry config virtualenvs.in-project "true" | |
$POETRY_HOME/bin/poetry --version | |
echo "bin=${{ env.POETRY_HOME }}/bin/poetry" >> $GITHUB_OUTPUT | |
- name: Install Python Dependencies | |
run: | | |
source ${{ steps.venv.outputs.location }}/bin/activate | |
make POETRY_BIN="${{ steps.poetry.outputs.bin }}" UPGRADE_PL=0 environment | |
# Adding this install outside of poetry as the dependencies conflict with existing other packages. | |
# TODO: This needs to be revisited. | |
${{ steps.venv.outputs.location }}/bin/python3 -m pip install --no-deps mitiq==0.25.0 | |
- name: Build tutorials | |
run: | | |
make download | |
make html | |
zip -r /tmp/qml_demos.zip demos | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: built-website-master | |
path: | | |
/tmp/qml_demos.zip | |
_build/html | |
check-diffs: | |
runs-on: ubuntu-latest | |
needs: [build-dev, build-master] | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
# We checkout a dedicated unprotected branch and store the output of | |
# the checker there | |
ref: demo_output_comparison | |
- name: Create dev dir | |
run: mkdir /tmp/dev/ | |
- uses: actions/download-artifact@v2 | |
with: | |
name: built-website-dev | |
path: /tmp/dev/ | |
- name: Create master dir | |
run: mkdir /tmp/master/ | |
- uses: actions/download-artifact@v2 | |
with: | |
name: built-website-master | |
path: /tmp/master/ | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Update the output file | |
run: | | |
git config user.name "QML demo checker Bot" | |
git config user.email "<>" | |
pip install pytz | |
python .github/workflows/generate_diffs.py | |
mv demo_diffs.md demo_checker | |
git add demo_checker/demo_diffs.md | |
git commit -m "Update the demonstration differences found" | |
git push | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: demo_diffs | |
path: | | |
demo_checker/demo_diffs.md |