Add a builder api #1049
This file contains hidden or 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: Build & test all configs | |
| on: [ push, pull_request ] | |
| jobs: | |
| release-notice: | |
| name: This is a release build | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Show version | |
| run: echo "This is a release build for v${GITHUB_REF/refs\/tags\/v/}" | |
| build: | |
| strategy: | |
| matrix: | |
| crate: | |
| - { name: "vhdl_lang", binary: true } | |
| - { name: "vhdl_ls", binary: true } | |
| - { name: "vhdl_syntax", binary: false } | |
| - { name: "vhdl-dump-ast", binary: false } | |
| target: | |
| - x86_64-unknown-linux-gnu | |
| - x86_64-unknown-linux-musl | |
| - x86_64-pc-windows-msvc | |
| - aarch64-apple-darwin | |
| rust: | |
| - stable | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| ext: "" | |
| - target: x86_64-unknown-linux-musl | |
| os: ubuntu-latest | |
| ext: "" | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| ext: .exe | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| ext: "" | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Setup Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: ${{ matrix.rust }} | |
| target: ${{ matrix.target }} | |
| components: rustfmt, clippy | |
| - name: Cache cargo | |
| uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: ${{ runner.os }}-${{ matrix.target }}-${{ matrix.rust }}-${{ matrix.crate.name }}-${{ hashFiles('**/Cargo.lock') }} | |
| - uses: awalsh128/cache-apt-pkgs-action@5902b33ae29014e6ca012c5d8025d4346556bd40 # v1.5.0 | |
| if: matrix.os == 'ubuntu-latest' | |
| with: | |
| packages: musl-tools # provides musl-gcc | |
| version: 1.0 | |
| - name: Build | |
| run: cargo build --manifest-path ${{ matrix.crate.name }}/Cargo.toml --release --target ${{ matrix.target }} | |
| - name: Test | |
| if: matrix.os != 'macos-latest' # There are no free runners for Apple Silicon available at the moment | |
| run: cargo test --manifest-path ${{ matrix.crate.name }}/Cargo.toml --release --target ${{ matrix.target }} | |
| - name: rustfmt | |
| if: ${{ matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-gnu' && matrix.rust == 'stable' }} | |
| run: cargo fmt --manifest-path ${{ matrix.crate.name }}/Cargo.toml -- --check | |
| - name: clippy | |
| if: ${{ matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-gnu' && matrix.rust == 'stable' }} | |
| run: cargo clippy --manifest-path ${{ matrix.crate.name }}/Cargo.toml --all-targets --all-features -- -D warnings | |
| - name: Assemble | |
| if: ${{ matrix.crate.binary == true && matrix.rust == 'stable' }} | |
| run: | | |
| mkdir ${{ matrix.crate.name }}-${{ matrix.target }} | |
| mkdir ${{ matrix.crate.name }}-${{ matrix.target }}/bin | |
| cp -R vhdl_libraries ${{ matrix.crate.name }}-${{ matrix.target }} | |
| cp target/${{ matrix.target }}/release/${{ matrix.crate.name }}${{ matrix.ext }} ${{ matrix.crate.name }}-${{ matrix.target }}/bin | |
| - name: Upload | |
| if: ${{ matrix.crate.binary == true && matrix.rust == 'stable' }} | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: ${{ matrix.crate.name }}-${{ matrix.target }} | |
| path: ${{ matrix.crate.name }}-${{ matrix.target }} | |
| codegen-check: | |
| name: Check generated code for vhdl_syntax is up-to-date | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt | |
| - name: Check generated code is up-to-date | |
| run: cargo xtask codegen --check | |
| release: | |
| name: Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Get version | |
| id: v | |
| run: | | |
| echo "v=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV | |
| echo "Version is v${GITHUB_REF/refs\/tags\/v/}" | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| pattern: vhdl_* | |
| path: ~/temp | |
| - name: Check vhdl_lang version | |
| run: | | |
| chmod u+x ~/temp/vhdl_lang-x86_64-unknown-linux-musl/bin/vhdl_lang | |
| version_string=$(~/temp/vhdl_lang-x86_64-unknown-linux-musl/bin/vhdl_lang --version) | |
| if [ "$version_string" != "vhdl_lang $v" ] | |
| then | |
| echo "Version string mismatch (\"$version_string\" != \"vhdl_lang $v\"" | |
| exit 1 | |
| else | |
| echo "Version string matched" | |
| fi | |
| - name: Check vhdl_ls version | |
| run: | | |
| chmod u+x ~/temp/vhdl_ls-x86_64-unknown-linux-musl/bin/vhdl_ls | |
| version_string=$(~/temp/vhdl_ls-x86_64-unknown-linux-musl/bin/vhdl_ls --version) | |
| if [ "$version_string" != "vhdl_ls $v" ] | |
| then | |
| echo "Version string mismatch (\"$version_string\" != \"vhdl_ls $v\"" | |
| exit 1 | |
| else | |
| echo "Version string matched" | |
| fi | |
| - name: Zip artifacts | |
| run: | | |
| cd ~/temp | |
| chmod +x */bin/vhdl* | |
| zip -r vhdl_lang-x86_64-unknown-linux-gnu.zip vhdl_lang-x86_64-unknown-linux-gnu | |
| zip -r vhdl_ls-x86_64-unknown-linux-gnu.zip vhdl_ls-x86_64-unknown-linux-gnu | |
| zip -r vhdl_lang-x86_64-unknown-linux-musl.zip vhdl_lang-x86_64-unknown-linux-musl | |
| zip -r vhdl_ls-x86_64-unknown-linux-musl.zip vhdl_ls-x86_64-unknown-linux-musl | |
| zip -r vhdl_lang-x86_64-pc-windows-msvc.zip vhdl_lang-x86_64-pc-windows-msvc | |
| zip -r vhdl_ls-x86_64-pc-windows-msvc.zip vhdl_ls-x86_64-pc-windows-msvc | |
| zip -r vhdl_ls-aarch64-apple-darwin.zip vhdl_ls-aarch64-apple-darwin | |
| zip -r vhdl_lang-aarch64-apple-darwin.zip vhdl_lang-aarch64-apple-darwin | |
| - name: Do release | |
| uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0 | |
| with: | |
| draft: false | |
| artifacts: "~/temp/*.zip" | |
| token: ${{ secrets.GITHUB_TOKEN }} |