|
1 | | -# This workflow will build and test PEx, and cache/restore any dependencies to improve the workflow execution time |
| 1 | +# This workflow will use the published PEx Maven package instead of building it locally |
2 | 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven |
3 | 3 |
|
4 | 4 | name: PEx on Ubuntu |
|
12 | 12 | description: Additional arguments |
13 | 13 | default: "" |
14 | 14 | required: false |
| 15 | + pex_version: |
| 16 | + description: PEx version to use (defaults to latest published version) |
| 17 | + required: false |
| 18 | + type: string |
15 | 19 | jobs: |
16 | | - PEx-Build-And-Test-Ubuntu: |
| 20 | + PEx-Setup-And-Test-Ubuntu: |
17 | 21 | runs-on: ubuntu-latest |
18 | 22 | steps: |
19 | 23 | - uses: actions/checkout@v1 |
|
31 | 35 | path: ~/.m2 |
32 | 36 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
33 | 37 | restore-keys: ${{ runner.os }}-m2 |
34 | | - - name: Build PEx |
35 | | - working-directory: Src/PEx |
36 | | - run: ./scripts/build_and_test.sh --build |
37 | | - - name: Test PEx |
38 | | - working-directory: Src/PEx |
39 | | - run: ./scripts/build_and_test.sh --test |
| 38 | + - name: Determine PEx version |
| 39 | + id: pex_version |
| 40 | + run: | |
| 41 | + # Use the version provided in the workflow input, or default to the latest version in pom.xml |
| 42 | + if [ -n "${{ github.event.inputs.pex_version }}" ]; then |
| 43 | + PEX_VERSION="${{ github.event.inputs.pex_version }}" |
| 44 | + else |
| 45 | + # Extract the version from the PEx pom.xml |
| 46 | + PEX_VERSION=$(grep -oP '<revision>\K[^<]+' Src/PEx/pom.xml) |
| 47 | + fi |
| 48 | + echo "PEX_VERSION=${PEX_VERSION}" >> $GITHUB_ENV |
| 49 | + echo "Using PEx version: ${PEX_VERSION}" |
| 50 | + - name: Add PEx Maven dependency |
| 51 | + run: | |
| 52 | + echo "Using published PEx Maven package (io.github.p-org:pex:${PEX_VERSION}) instead of building locally" |
| 53 | + # The P compiler will automatically use the published package from Maven Central |
| 54 | + - name: Install P as a tool |
| 55 | + run: dotnet tool install --global p |
| 56 | + - name: Test with published PEx package |
| 57 | + run: | |
| 58 | + # Navigate to the ClientServer tutorial |
| 59 | + cd Tutorial/1_ClientServer |
| 60 | + |
| 61 | + # Compile the P program |
| 62 | + echo "Compiling ClientServer tutorial with published PEx package..." |
| 63 | + p compile --mode pex |
| 64 | + |
| 65 | + # Check if compilation was successful |
| 66 | + if [ $? -ne 0 ]; then |
| 67 | + echo "Error: Failed to compile ClientServer tutorial" |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | + |
| 71 | + # Run a test case |
| 72 | + echo "Running test case with published PEx package..." |
| 73 | + p check --mode pex -tc tcSingleClient --timeout 60 |
| 74 | + |
| 75 | + # Check if test was successful |
| 76 | + if [ $? -ne 0 ]; then |
| 77 | + echo "Error: Test case failed" |
| 78 | + exit 1 |
| 79 | + fi |
| 80 | + |
| 81 | + echo "Successfully tested published PEx package (io.github.p-org:pex:${PEX_VERSION})" |
0 commit comments