Merge upstream 0.3.0 beta into our fork for less unsafe #29
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: CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: | |
- master | |
- v0.3 | |
workflow_dispatch: | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_VERSION: nightly-2021-11-30 | |
jobs: | |
tests-antlr: | |
name: ANTLR4 testsuite | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
repository: rrevenantt/antlr4 | |
ref: rust-target | |
submodules: true | |
- run: | | |
git remote add signavio_fork [email protected]:signavio/antlr4rust.git | |
git fetch signavio_fork $GITHUB_REF | |
git checkout FETCH_HEAD | |
working-directory: runtime/Rust | |
- name: Set up JDK 1.8 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '8' | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
default: true | |
- name: Cache local Maven repository | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Build with Maven | |
run : mvn -DskipTests install -q | |
- name : Maven tests | |
run: | | |
mvn test -Dtest=rust.* -q | |
rc=$?; | |
cat target/surefire-reports/*.dumpstream || true; | |
exit $rc | |
working-directory: runtime-testsuite | |
- uses: actions/upload-artifact@v3 | |
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | |
with: | |
name: antlr-tool | |
path: tool/target/antlr4-4.8-2-SNAPSHOT-complete.jar | |
tests-rust: | |
name: cargo test | |
runs-on: ubuntu-latest | |
outputs: | |
new_version: ${{ steps.check_ver.outputs.new_version }} | |
strategy: | |
fail-fast: false | |
matrix: | |
rust_version: [ 1.52, stable ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ env.RUST_VERSION }} | |
default: true | |
components: rustfmt | |
- name: Build | |
run: cargo build --verbose | |
- name: Run tests | |
run: cargo test --verbose | |
- name: Formatting | |
run: cargo fmt -- --check | |
- uses: actions/checkout@v3 | |
if: ${{ github.event_name == 'push' }} | |
with: | |
ref: ${{ github.event.before }} | |
path: base_branch | |
- name: check version bump | |
if: ${{ github.event_name == 'push' }} | |
id: check_ver | |
run: | | |
NEW_VER=$(cat Cargo.toml | sed -nE "s/^version.*\"([0-9a-z.\-]+)\".*$/\1/p") | |
BASE_VER=$(cat base_branch/Cargo.toml | sed -nE "s/^version.*\"([0-9a-z.\-]+)\".*$/\1/p") | |
if [[ "$NEW_VER" != "$BASE_VER" ]]; then | |
echo "{new_version}={$NEW_VER}" >> $GITHUB_OUTPUT | |
fi | |
publish: | |
runs-on: ubuntu-latest | |
if: | | |
success() && github.event_name == 'push' | |
&& needs.tests-rust.outputs.new_version != null | |
&& needs.tests-rust.outputs.new_version != '' | |
needs: [tests-rust,tests-antlr] | |
env: | |
RELEASE_NAME: ${{ format('antlr4-4.8-2-Rust{0}',needs.tests-rust.outputs.new_version) }} | |
PRERELEASE: ${{ contains(needs.tests-rust.outputs.new_version, '-') }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
default: true | |
- name: Cargo publish check | |
run: | | |
cargo publish --dry-run | |
- uses: actions/download-artifact@v3 | |
with: | |
name: antlr-tool | |
- name: Create release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ env.RELEASE_NAME }} | |
name: ${{ env.RELEASE_NAME }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# make release a draft first in case `cargo publish` still fail | |
draft: true | |
prerelease: ${{ env.PRERELEASE }} | |
files: | | |
antlr4-4.8-2-SNAPSHOT-complete.jar | |
- name: Cargo publish | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_PUBLISH_TOKEN }} | |
run: | | |
git clean -f | |
cargo publish | |
- name: Publish github release | |
# todo use release-drafter/release-drafter@v5 | |
uses: eregon/publish-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
release_id: ${{ steps.create_release.outputs.release_id }} |