diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 4e273b5..9fb6914 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -22,8 +22,8 @@ jobs: - name: Build with Maven run: mvn -B package --file pom.xml - create-java-parser: - name: Create Java parser + create-test-java-parser: + name: Create and test Java parser needs: test-grammar runs-on: ubuntu-latest steps: @@ -43,11 +43,11 @@ jobs: - name: Archive Java parser uses: actions/upload-artifact@v3 with: - name: yarspg-java-parser + name: yarspg-java-parser.jar path: ${{ github.workspace }}/parsers/java/target/yarspg-java-parser.jar - create-python-parser: - name: Create Python parser + create-test-python-parser: + name: Create and test Python parser needs: test-grammar runs-on: ubuntu-latest steps: @@ -71,13 +71,13 @@ jobs: - name: Archive Python parser uses: actions/upload-artifact@v3 with: - name: yarspg-python-parser + name: yarspg-python-parser.zip path: ${{ github.workspace }}/parsers/python/yarspg-python-parser.zip pre-release: name: Create pre-release runs-on: ubuntu-latest - needs: [create-java-parser, create-python-parser] + needs: [create-test-java-parser, create-test-python-parser] steps: - uses: actions/checkout@v4 @@ -85,14 +85,14 @@ jobs: - name: Download Java parser artifact uses: actions/download-artifact@v3 with: - name: yarspg-java-parser + name: yarspg-java-parser.jar path: . # Download the Python parser artifact - name: Download Python parser artifact uses: actions/download-artifact@v3 with: - name: yarspg-python-parser + name: yarspg-python-parser.zip path: . - name: Wait for concurrent jobs @@ -111,4 +111,4 @@ jobs: yarspg/YARSpg.g4 other-notations/* yarspg-java-parser.jar - yarspg-python-parser.zip \ No newline at end of file + yarspg-python-parser.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a392590..ef0d9fa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: tags: - - "v*" + - "v[0-9]+.[0-9]+.[0-9]+" jobs: test-grammar: @@ -22,8 +22,8 @@ jobs: - name: Build with Maven run: mvn -B package --file pom.xml - create-java-parser: - name: Create Java parser + create-test-java-parser: + name: Create and test Java parser needs: test-grammar runs-on: ubuntu-latest steps: @@ -43,11 +43,11 @@ jobs: - name: Archive Java parser uses: actions/upload-artifact@v3 with: - name: yarspg-java-parser + name: yarspg-java-parser.jar path: ${{ github.workspace }}/parsers/java/target/yarspg-java-parser.jar - create-python-parser: - name: Create Python parser + create-test-python-parser: + name: Create and test Python parser needs: test-grammar runs-on: ubuntu-latest steps: @@ -71,13 +71,13 @@ jobs: - name: Archive Python parser uses: actions/upload-artifact@v3 with: - name: yarspg-python-parser + name: yarspg-python-parser.zip path: ${{ github.workspace }}/parsers/python/yarspg-python-parser.zip release: name: Create release runs-on: ubuntu-latest - needs: [create-java-parser, create-python-parser] + needs: [create-test-java-parser, create-test-python-parser] steps: - uses: actions/checkout@v4 @@ -85,14 +85,14 @@ jobs: - name: Download Java parser artifact uses: actions/download-artifact@v3 with: - name: yarspg-java-parser + name: yarspg-java-parser.jar path: . # Download the Python parser artifact - name: Download Python parser artifact uses: actions/download-artifact@v3 with: - name: yarspg-python-parser + name: yarspg-python-parser.zip path: . - name: Wait for concurrent jobs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3c738de --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,68 @@ +# Tests on every push (excluding main branch) and pull request + +name: Test + +on: + push: + branches-ignore: + - main + pull_request: + +jobs: + test-grammar: + name: Test grammar + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + cache: "maven" # caching Maven dependencies + cache-dependency-path: "pom.xml" + - name: Build with Maven + run: mvn -B package --file pom.xml + + create-test-java-parser: + name: Create and test Java parser + needs: test-grammar + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + cache: "maven" # caching Maven dependencies + cache-dependency-path: "parsers/java/pom.xml" + - name: Build Java parser + run: mvn -B package --file ${{ github.workspace }}/parsers/java/pom.xml && mv ${{ github.workspace }}/parsers/java/target/yarspg-java-parser*.jar ${{ github.workspace }}/parsers/java/target/yarspg-java-parser.jar + - name: Test Java parser + run: | + java -jar ${{ github.workspace }}/parsers/java/target/yarspg-java-parser.jar ${{ github.workspace }}/yarspg/examples/test-example.yarspg + + create-test-python-parser: + name: Create and test Python parser + needs: test-grammar + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + cache: "pip" # caching pip dependencies + cache-dependency-path: "parsers/python/requirements.txt" + - name: Install pip dependencies + run: python -m pip install -r ${{ github.workspace }}/parsers/python/requirements.txt + - name: Download the ANTRL4 Java binaries + run: curl -O https://www.antlr.org/download/antlr-4.13.1-complete.jar + - name: Generate the Python parser + run: | + java -jar antlr-4.13.1-complete.jar -Dlanguage=Python3 -o ${{ github.workspace }}/parsers/python ${{ github.workspace }}/yarspg/YARSpg.g4 + zip -j ${{ github.workspace }}/parsers/python/yarspg-python-parser.zip ${{ github.workspace }}/parsers/python/* + - name: Test Python parser + run: python ${{ github.workspace }}/parsers/python/yarspg_python_parser.py ${{ github.workspace }}/yarspg/examples/test-example.yarspg