|
| 1 | +name: Reference Python Package |
| 2 | + |
| 3 | +on: |
| 4 | + [push, pull_request] |
| 5 | + |
| 6 | +jobs: |
| 7 | + tests: |
| 8 | + name: OpenPulse AST tests |
| 9 | + runs-on: ubuntu-latest |
| 10 | + strategy: |
| 11 | + fail-fast: false |
| 12 | + matrix: |
| 13 | + python-version: ['3.7', '3.8', '3.9', '3.10'] |
| 14 | + antlr-version: ['4.9.2'] |
| 15 | + defaults: |
| 16 | + run: |
| 17 | + working-directory: source/openpulse |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + with: |
| 22 | + submodules: recursive |
| 23 | + |
| 24 | + - uses: actions/setup-python@v2 |
| 25 | + with: |
| 26 | + python-version: ${{ matrix.python-version }} |
| 27 | + |
| 28 | + - uses: actions/setup-java@v2 |
| 29 | + with: |
| 30 | + java-version: '15' |
| 31 | + distribution: 'adopt' |
| 32 | + |
| 33 | + - name: Update pip |
| 34 | + run: python -mpip install --upgrade pip |
| 35 | + |
| 36 | + - name: Install ANTLR4 |
| 37 | + working-directory: . |
| 38 | + run: curl -O https://www.antlr.org/download/antlr-${{ matrix.antlr-version }}-complete.jar |
| 39 | + |
| 40 | + - name: Install ANTLR4 Python runtime |
| 41 | + run: python -mpip install antlr4-python3-runtime==${{ matrix.antlr-version }} |
| 42 | + |
| 43 | + - name: Generate openqasm3 grammar |
| 44 | + working-directory: openqasm/source/grammar |
| 45 | + run: java -Xmx500M -jar ../../../antlr-${{ matrix.antlr-version }}-complete.jar -o ../openqasm/openqasm3/antlr -Dlanguage=Python3 -visitor qasm3Lexer.g4 qasm3Parser.g4 |
| 46 | + |
| 47 | + - name: Install Python dependencies |
| 48 | + working-directory: openqasm/source/openqasm |
| 49 | + run: python -mpip install -r requirements.txt -r requirements-dev.txt |
| 50 | + |
| 51 | + - name: Build openqasm3 package |
| 52 | + working-directory: openqasm/source/openqasm |
| 53 | + run: python -mpip install -e .[all] |
| 54 | + |
| 55 | + - name: Generate openpulse grammar |
| 56 | + working-directory: source/grammar |
| 57 | + run: java -Xmx500M -jar ../../antlr-${{ matrix.antlr-version }}-complete.jar -lib ../../openqasm/source/grammar -o ../openpulse/openpulse/antlr -Dlanguage=Python3 -visitor openpulseLexer.g4 openpulseParser.g4 |
| 58 | + |
| 59 | + - name: Check openpulse format |
| 60 | + run: black --check --diff openpulse tests |
| 61 | + |
| 62 | + - name: Check openpulse style |
| 63 | + working-directory: source/openpulse/openpulse |
| 64 | + run: pylint . |
| 65 | + |
| 66 | + - name: Check openpulse tests style |
| 67 | + working-directory: source/openpulse/tests |
| 68 | + run: pylint . |
| 69 | + |
| 70 | + - name: Run openpulse tests |
| 71 | + run: pytest -vv --color=yes tests |
0 commit comments