Skip to content

Commit 03b219c

Browse files
authored
Support building Dafny from source (#26)
Adds optional build-from-source input.
1 parent 3d43eac commit 03b219c

4 files changed

Lines changed: 102 additions & 9 deletions

File tree

.github/workflows/main.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
os: [macos-latest, ubuntu-latest, windows-latest]
18-
dafny: [3.0.0, 3.8.1, 3.13.1, 4.0.0, nightly-2023-02-28-80a0e49, nightly-latest]
19-
# Windows 2.3.0 requires mono
18+
dafny: [3.8.1, 3.13.1, 4.0.0, 4.9.1, nightly-2023-02-28-80a0e49, nightly-latest]
2019
include:
21-
- os: macos-latest
22-
dafny: 2.3.0
23-
- os: ubuntu-latest
24-
dafny: 2.3.0
20+
# Test building from source from a subset of versions
21+
- dafny: 4.0.0
22+
build-from-source: v4.0.0
23+
- dafny: 4.9.0
24+
build-from-source: v4.9.0
25+
2526
steps:
2627
# The first call to `dotnet tool` on a fresh runner sometimes takes multiple minutes,
2728
# perhaps because it is lazily downloading and installing assets.
@@ -36,6 +37,7 @@ jobs:
3637
uses: ./
3738
with:
3839
dafny-version: ${{ matrix.dafny }}
40+
build-from-source: ${{ matrix.build-from-source }}
3941

4042
- name: verify dafny
4143
shell: bash

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ If you need to use a specific version:
1616
- name: "Install Dafny"
1717
uses: dafny-lang/setup-dafny-action@v1
1818
with:
19-
dafny-version: "2.3.0"
19+
dafny-version: "4.9.1"
2020
```
2121
2222
You can also use `nightly-latest` to install the most recent nightly pre-release.
@@ -26,3 +26,21 @@ containing the actual resolved Dafny version: particularly useful for `nightly-l
2626

2727
This action transparently works on macOS by detecting the running OS. You can
2828
just set `runs-on` to a macOS virtual environment like `macos-latest`.
29+
30+
You can also build Dafny from source,
31+
if you want to run against a branch of Dafny still in development:
32+
33+
```yml
34+
- name: "Install Dafny"
35+
uses: dafny-lang/setup-dafny-action@v1
36+
with:
37+
dafny-version: "4.9.1"
38+
build-from-source: support-puppies-and-rainbows
39+
40+
```
41+
42+
`build-from-source` can be set to a branch name, tag, commit sha,
43+
and so on: anything that `actions/checkout` understands.
44+
Note that `dafny-version` is still currently required
45+
in order to still set the `DAFNY_VERSION` environment variable,
46+
as it is not automatically extracted from the built Dafny.

action.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,33 @@ inputs:
88
description: "Dafny version to install"
99
required: true
1010
default: "3.1.0"
11+
build-from-source:
12+
description: "dafny-lang/dafny commit-ish to build"
13+
required: false
1114
runs:
1215
using: "composite"
1316
steps:
17+
1418
- uses: actions/setup-dotnet@v4
1519
with:
1620
dotnet-version: '6.0.x'
17-
- uses: actions/setup-node@v4
21+
22+
- if: ${{ !inputs.build-from-source }}
23+
uses: actions/setup-node@v4
1824
with:
1925
node-version: 16
20-
- run: node $GITHUB_ACTION_PATH/dist/index.js
26+
- if: ${{ !inputs.build-from-source }}
27+
run: node $GITHUB_ACTION_PATH/dist/index.js
2128
shell: bash
2229
env:
2330
INPUT_DAFNY-VERSION: ${{ inputs.dafny-version }}
31+
32+
- if: ${{ inputs.build-from-source }}
33+
uses: actions/setup-dotnet@v4
34+
with:
35+
dotnet-version: '8.0.x'
36+
- if: ${{ inputs.build-from-source }}
37+
uses: ./build_dafny_from_source
38+
with:
39+
dafny-version: ${{ inputs.dafny-version }}
40+
ref: ${{ inputs.build-from-source }}

build_dafny_from_source/action.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Build Dafny from source"
2+
description: "Builds the given branch of Dafny from source"
3+
inputs:
4+
dafny-version:
5+
description: "Dafny version to build from source"
6+
required: true
7+
type: string
8+
ref:
9+
description: "The Dafny branch, tag or SHA to build"
10+
required: true
11+
type: string
12+
runs:
13+
using: "composite"
14+
steps:
15+
- uses: actions/setup-java@v3
16+
with:
17+
distribution: "corretto"
18+
java-version: "17"
19+
20+
- name: Checkout Dafny
21+
uses: actions/checkout@v4
22+
with:
23+
repository: dafny-lang/dafny
24+
path: dafny
25+
ref: ${{ inputs.ref }}
26+
27+
- name: Setup Z3
28+
uses: cda-tum/setup-z3@v1.6.3
29+
with:
30+
version: 4.12.1
31+
32+
- name: Build Dafny
33+
shell: bash
34+
run: |
35+
make -C dafny exe
36+
37+
- name: Add dafny to PATH (non-Windows)
38+
if: runner.os != 'Windows'
39+
shell: bash
40+
run: |
41+
echo ${{ github.workspace }}/dafny/Scripts >> $GITHUB_PATH
42+
- name: Add dafny to PATH (Windows)
43+
if: runner.os == 'Windows'
44+
shell: pwsh
45+
run: |
46+
Add-Content $env:GITHUB_PATH "${{ github.workspace }}/dafny/Scripts"
47+
48+
- name: Export DAFNY_VERSION
49+
shell: bash
50+
run: |
51+
echo "DAFNY_VERSION=${{ inputs.dafny-version }}" >> $GITHUB_ENV
52+
53+
- name: Install reportgenerator
54+
shell: bash
55+
run: |
56+
dotnet tool install -g dafny-reportgenerator --version 1.*

0 commit comments

Comments
 (0)