Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building Dafny from source #26

Merged
merged 21 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
dafny: [3.0.0, 3.8.1, 3.13.1, 4.0.0, nightly-2023-02-28-80a0e49, nightly-latest]
# Windows 2.3.0 requires mono
dafny: [3.8.1, 3.13.1, 4.0.0, 4.9.1, nightly-2023-02-28-80a0e49, nightly-latest]
include:
- os: macos-latest
dafny: 2.3.0
- os: ubuntu-latest
dafny: 2.3.0
# Test building from source from a subset of versions
- dafny: 4.0.0
build-from-source: v4.0.0
- dafny: 4.9.0
build-from-source: v4.9.0

steps:
# The first call to `dotnet tool` on a fresh runner sometimes takes multiple minutes,
# perhaps because it is lazily downloading and installing assets.
Expand All @@ -36,6 +37,7 @@ jobs:
uses: ./
with:
dafny-version: ${{ matrix.dafny }}
build-from-source: ${{ matrix.build-from-source }}

- name: verify dafny
shell: bash
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ If you need to use a specific version:
- name: "Install Dafny"
uses: dafny-lang/setup-dafny-action@v1
with:
dafny-version: "2.3.0"
dafny-version: "4.9.1"
```
You can also use `nightly-latest` to install the most recent nightly pre-release.
Expand All @@ -26,3 +26,21 @@ containing the actual resolved Dafny version: particularly useful for `nightly-l

This action transparently works on macOS by detecting the running OS. You can
just set `runs-on` to a macOS virtual environment like `macos-latest`.

You can also build Dafny from source,
if you want to run against a branch of Dafny still in development:

```yml
- name: "Install Dafny"
uses: dafny-lang/setup-dafny-action@v1
with:
dafny-version: "4.9.1"
build-from-source: support-puppies-and-rainbows
```

`build-from-source` can be set to a branch name, tag, commit sha,
and so on: anything that `actions/checkout` understands.
Note that `dafny-version` is still currently required
in order to still set the `DAFNY_VERSION` environment variable,
as it is not automatically extracted from the built Dafny.
21 changes: 19 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,33 @@ inputs:
description: "Dafny version to install"
required: true
default: "3.1.0"
build-from-source:
description: "dafny-lang/dafny commit-ish to build"
required: false
runs:
using: "composite"
steps:

- uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- uses: actions/setup-node@v4

- if: ${{ !inputs.build-from-source }}
uses: actions/setup-node@v4
with:
node-version: 16
- run: node $GITHUB_ACTION_PATH/dist/index.js
- if: ${{ !inputs.build-from-source }}
run: node $GITHUB_ACTION_PATH/dist/index.js
shell: bash
env:
INPUT_DAFNY-VERSION: ${{ inputs.dafny-version }}

- if: ${{ inputs.build-from-source }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- if: ${{ inputs.build-from-source }}
uses: ./build_dafny_from_source
with:
dafny-version: ${{ inputs.dafny-version }}
ref: ${{ inputs.build-from-source }}
56 changes: 56 additions & 0 deletions build_dafny_from_source/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Build Dafny from source"
description: "Builds the given branch of Dafny from source"
inputs:
dafny-version:
description: "Dafny version to build from source"
required: true
type: string
ref:
description: "The Dafny branch, tag or SHA to build"
required: true
type: string
runs:
using: "composite"
steps:
- uses: actions/setup-java@v3
with:
distribution: "corretto"
java-version: "17"

- name: Checkout Dafny
uses: actions/checkout@v4
with:
repository: dafny-lang/dafny
path: dafny
ref: ${{ inputs.ref }}

- name: Setup Z3
uses: cda-tum/[email protected]
with:
version: 4.12.1

- name: Build Dafny
shell: bash
run: |
make -C dafny exe

- name: Add dafny to PATH (non-Windows)
if: runner.os != 'Windows'
shell: bash
run: |
echo ${{ github.workspace }}/dafny/Scripts >> $GITHUB_PATH
- name: Add dafny to PATH (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Add-Content $env:GITHUB_PATH "${{ github.workspace }}/dafny/Scripts"

- name: Export DAFNY_VERSION
shell: bash
run: |
echo "DAFNY_VERSION=${{ inputs.dafny-version }}" >> $GITHUB_ENV

- name: Install reportgenerator
shell: bash
run: |
dotnet tool install -g dafny-reportgenerator --version 1.*
Loading