|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v[0-9]+.[0-9]+.[0-9]+' |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + RUST_BACKTRACE: 1 |
| 11 | + |
| 12 | +jobs: |
| 13 | + build-and-release: |
| 14 | + name: Build ${{ matrix.target }} |
| 15 | + permissions: |
| 16 | + contents: read |
| 17 | + runs-on: ${{ matrix.runner }} |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + # Linux x86_64 |
| 23 | + - target: x86_64-unknown-linux-gnu |
| 24 | + runner: self-hosted |
| 25 | + asset_name: x86_64-unknown-linux-gnu |
| 26 | + |
| 27 | + # Linux ARM64 (aarch64) |
| 28 | + - target: aarch64-unknown-linux-gnu |
| 29 | + runner: ubuntu-24.04-arm |
| 30 | + asset_name: aarch64-unknown-linux-gnu |
| 31 | + |
| 32 | + # macOS x86_64 |
| 33 | + - target: x86_64-apple-darwin |
| 34 | + runner: macos-13 |
| 35 | + asset_name: x86_64-apple-darwin |
| 36 | + |
| 37 | + # macOS ARM64 |
| 38 | + - target: aarch64-apple-darwin |
| 39 | + runner: macos-latest |
| 40 | + asset_name: aarch64-apple-darwin |
| 41 | + |
| 42 | + # Windows x86_64 |
| 43 | + - target: x86_64-pc-windows-msvc |
| 44 | + runner: windows-latest |
| 45 | + asset_name: x86_64-windows |
| 46 | + binary_ext: .exe |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Checkout code |
| 50 | + uses: actions/checkout@v4 |
| 51 | + with: |
| 52 | + fetch-depth: 0 # Need full history to verify tag is from "main" branch |
| 53 | + |
| 54 | + # - name: Verify tag is from main branch |
| 55 | + # shell: bash |
| 56 | + # run: | |
| 57 | + # # Get the commit SHA that the tag points to |
| 58 | + # TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref }}) |
| 59 | + # |
| 60 | + # # Check if this commit exists on main branch |
| 61 | + # git fetch origin main |
| 62 | + # if ! git merge-base --is-ancestor $TAG_COMMIT origin/main; then |
| 63 | + # echo "Error: Tag must be created from main branch!" |
| 64 | + # echo "This tag points to commit $TAG_COMMIT which is not on main branch." |
| 65 | + # exit 1 |
| 66 | + # fi |
| 67 | + # echo "Tag is from main branch (commit: $TAG_COMMIT)" |
| 68 | + # |
| 69 | + # # Make sure that Cargo.toml version for each tool is the same as the tag |
| 70 | + # - name: Verify version consistency |
| 71 | + # shell: bash |
| 72 | + # run: | |
| 73 | + # # Extract version from tag |
| 74 | + # TAG_VERSION="${GITHUB_REF#refs/tags/v}" |
| 75 | + # |
| 76 | + # # Check each tool's Cargo.toml version |
| 77 | + # for tool in move-mutation-test move-mutator move-spec-test; do |
| 78 | + # CARGO_VERSION=$(grep "^version" $tool/Cargo.toml | head -1 | cut -d'"' -f2) |
| 79 | + # if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then |
| 80 | + # echo "Error: Version mismatch for $tool!" |
| 81 | + # echo " Tag version: $TAG_VERSION" |
| 82 | + # echo " Cargo.toml version: $CARGO_VERSION" |
| 83 | + # exit 1 |
| 84 | + # fi |
| 85 | + # echo "$tool version matches: $CARGO_VERSION" |
| 86 | + # done |
| 87 | + |
| 88 | + - name: Enable long paths on Windows |
| 89 | + if: runner.os == 'Windows' |
| 90 | + run: | |
| 91 | + git config --system core.longpaths true |
| 92 | + reg add HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f |
| 93 | + shell: pwsh |
| 94 | + |
| 95 | + - name: Install required deps |
| 96 | + if: runner.os == 'Linux' |
| 97 | + run: sudo apt-get install libssl-dev pkg-config libudev-dev libdw-dev |
| 98 | + |
| 99 | + - name: Install Rust toolchain |
| 100 | + uses: dtolnay/rust-toolchain@stable |
| 101 | + |
| 102 | + - name: Install Aptos CLI |
| 103 | + shell: bash |
| 104 | + run: | |
| 105 | + if [ "${{ runner.os }}" = "macOS" ]; then |
| 106 | + echo "Installing Aptos CLI via Homebrew..." |
| 107 | + brew install aptos |
| 108 | + elif [ "${{ runner.os }}" = "Windows" ]; then |
| 109 | + echo "Installing Aptos CLI via Chocolatey..." |
| 110 | + choco install aptos -y |
| 111 | + else |
| 112 | + echo "Installing Aptos CLI via installer script..." |
| 113 | + curl -fsSL "https://aptos.dev/scripts/install_cli.sh" | sh |
| 114 | + source ~/.profile |
| 115 | + APTOS_PATH=$(dirname $(which aptos)) |
| 116 | + echo "$APTOS_PATH" >> $GITHUB_PATH |
| 117 | + fi |
| 118 | + aptos --version |
| 119 | +
|
| 120 | + - name: Cache Cargo |
| 121 | + uses: actions/cache@v4 |
| 122 | + with: |
| 123 | + path: | |
| 124 | + ~/.cargo/bin/ |
| 125 | + ~/.cargo/registry/index/ |
| 126 | + ~/.cargo/registry/cache/ |
| 127 | + ~/.cargo/git/db/ |
| 128 | + target/ |
| 129 | + key: ${{ runner.os }}-${{ matrix.target }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} |
| 130 | + |
| 131 | + - name: Build all tools |
| 132 | + shell: bash |
| 133 | + run: | |
| 134 | + cargo build --release --bin move-mutation-test |
| 135 | + cargo build --release --bin move-mutator |
| 136 | + cargo build --release --bin move-spec-test |
| 137 | +
|
| 138 | + - name: Basic smoke test |
| 139 | + shell: bash |
| 140 | + run: | |
| 141 | + ./target/release/move-mutation-test${{ matrix.binary_ext }} --version |
| 142 | + ./target/release/move-mutator${{ matrix.binary_ext }} --version |
| 143 | + ./target/release/move-spec-test${{ matrix.binary_ext }} --version |
| 144 | +
|
| 145 | + - name: Test move-mutation-test tool on simple_move_2_features (Linux, Mac, Windows) |
| 146 | + shell: bash |
| 147 | + run: | |
| 148 | + if [ "${{ runner.os }}" = "Windows" ]; then |
| 149 | + choco install unxutils strawberryperl |
| 150 | + fi |
| 151 | +
|
| 152 | + echo "Testing mutation tools on simple_move_2_features project..." |
| 153 | + cd move-mutator/tests/move-assets/simple_move_2_features |
| 154 | +
|
| 155 | + echo "Generating coverage data with aptos move test..." |
| 156 | + aptos move test --coverage |
| 157 | +
|
| 158 | + echo "Running move-mutation-test with coverage..." |
| 159 | + if [ "${{ runner.os }}" = "Windows" ]; then |
| 160 | + ../../../../target/release/move-mutation-test.exe run --coverage --output report-mutation-generated.txt |
| 161 | + else |
| 162 | + ../../../../target/release/move-mutation-test run --coverage --output report-mutation-generated.txt |
| 163 | + fi |
| 164 | +
|
| 165 | + if [ "${{ runner.os }}" = "Windows" ]; then |
| 166 | + # HACK: Normalize Windows path. This only works because we test a single Move project |
| 167 | + sed -i 's/"sources\\\\Operators.move"/"sources\/Operators.move"/g' report-mutation-generated.txt |
| 168 | + fi |
| 169 | +
|
| 170 | + # Remove trailing newlines from both files |
| 171 | + perl -pi -e 'chomp if eof' report-mutation-generated.txt |
| 172 | + perl -pi -e 'chomp if eof' report.txt.mutation-exp |
| 173 | +
|
| 174 | + # Get all lines except last 3 (excluding package_dir) |
| 175 | + LINES_GEN=$(wc -l < report-mutation-generated.txt) |
| 176 | + LINES_EXP=$(wc -l < report.txt.mutation-exp) |
| 177 | + KEEP_GEN=$((LINES_GEN - 3)) |
| 178 | + KEEP_EXP=$((LINES_EXP - 3)) |
| 179 | +
|
| 180 | + head -n "$KEEP_GEN" report-mutation-generated.txt > report-mutation-gen-trimmed.txt |
| 181 | + head -n "$KEEP_EXP" report.txt.mutation-exp > report-mutation-exp-trimmed.txt |
| 182 | +
|
| 183 | + if diff -B report-mutation-gen-trimmed.txt report-mutation-exp-trimmed.txt > /dev/null 2>&1; then |
| 184 | + echo "move-mutation-test report matches expected" |
| 185 | + rm -f report-mutation-gen-trimmed.txt report-mutation-exp-trimmed.txt |
| 186 | + else |
| 187 | + echo "move-mutation-test report differs from expected" |
| 188 | + echo "=== Differences ===" |
| 189 | + diff -B report-mutation-gen-trimmed.txt report-mutation-exp-trimmed.txt || true |
| 190 | + rm -f report-mutation-gen-trimmed.txt report-mutation-exp-trimmed.txt |
| 191 | + exit 1 |
| 192 | + fi |
| 193 | +
|
| 194 | + # Determine version for asset naming |
| 195 | + - name: Get version |
| 196 | + id: version |
| 197 | + shell: bash |
| 198 | + run: | |
| 199 | + # Extract version from tag (remove 'v' prefix) |
| 200 | + VERSION="${GITHUB_REF#refs/tags/v}" |
| 201 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 202 | +
|
| 203 | + - name: Package all tools for release |
| 204 | + shell: bash |
| 205 | + run: | |
| 206 | + mkdir -p package |
| 207 | +
|
| 208 | + cp target/release/move-mutation-test${{ matrix.binary_ext }} package/move-mutation-test${{ matrix.binary_ext }} |
| 209 | + cp target/release/move-mutator${{ matrix.binary_ext }} package/move-mutator${{ matrix.binary_ext }} |
| 210 | + cp target/release/move-spec-test${{ matrix.binary_ext }} package/move-spec-test${{ matrix.binary_ext }} |
| 211 | +
|
| 212 | + cd package |
| 213 | + if [ "${{ runner.os }}" = "Windows" ]; then |
| 214 | + 7z a -tzip ../mutation-tools-${{ matrix.asset_name }}.zip * |
| 215 | + else |
| 216 | + zip -r ../mutation-tools-${{ matrix.asset_name }}.zip * |
| 217 | + fi |
| 218 | + cd .. |
| 219 | +
|
| 220 | + - name: Upload release artifacts |
| 221 | + uses: actions/upload-artifact@v4 |
| 222 | + with: |
| 223 | + name: release-${{ matrix.target }} |
| 224 | + path: | |
| 225 | + mutation-tools-${{ matrix.asset_name }}.zip |
| 226 | +
|
| 227 | + create-release: |
| 228 | + name: Create GitHub Release |
| 229 | + runs-on: self-hosted |
| 230 | + needs: build-and-release |
| 231 | + permissions: |
| 232 | + contents: write |
| 233 | + |
| 234 | + steps: |
| 235 | + - name: Checkout code |
| 236 | + uses: actions/checkout@v4 |
| 237 | + |
| 238 | + - name: Determine version |
| 239 | + id: version |
| 240 | + run: | |
| 241 | + TAG="${GITHUB_REF#refs/tags/}" |
| 242 | + VERSION="${TAG#v}" |
| 243 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 244 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 245 | +
|
| 246 | + - name: Download all artifacts |
| 247 | + uses: actions/download-artifact@v4 |
| 248 | + with: |
| 249 | + path: artifacts |
| 250 | + |
| 251 | + - name: Prepare release assets |
| 252 | + run: | |
| 253 | + mkdir -p release-assets |
| 254 | + find artifacts -name "*.zip" | while read file; do |
| 255 | + cp "$file" release-assets/ |
| 256 | + done |
| 257 | + ls -lh release-assets/ |
| 258 | +
|
| 259 | + - name: Create GitHub Release |
| 260 | + uses: softprops/action-gh-release@v2 |
| 261 | + with: |
| 262 | + tag_name: ${{ steps.version.outputs.tag }} |
| 263 | + name: Move Mutation Tools v${{ steps.version.outputs.version }} |
| 264 | + body: | |
| 265 | + ## Installation Options |
| 266 | +
|
| 267 | + ### Via Aptos CLI (Recommended for most users) |
| 268 | + ```bash |
| 269 | + aptos update move-mutation-test |
| 270 | + ``` |
| 271 | + This installs `move-mutation-test` which is the main tool most users need. |
| 272 | +
|
| 273 | + ### Direct Download (All tools) |
| 274 | + Download the appropriate archive for your platform below. Each archive contains: |
| 275 | + - `move-mutation-test` - Tests the quality of your unit test suite |
| 276 | + - `move-mutator` - Core mutation engine for advanced users |
| 277 | + - `move-spec-test` - Tests the quality of your formal specifications |
| 278 | +
|
| 279 | + ## Platform Support |
| 280 | +
|
| 281 | + | Platform | Architecture | File | |
| 282 | + |----------|--------------|------| |
| 283 | + | Linux | x86_64 | `mutation-tools-x86_64-unknown-linux-gnu.zip` | |
| 284 | + | Linux | ARM64/aarch64 | `mutation-tools-aarch64-unknown-linux-gnu.zip` | |
| 285 | + | macOS | x86_64 (Intel) | `mutation-tools-x86_64-apple-darwin.zip` | |
| 286 | + | macOS | ARM64 (Apple Silicon) | `mutation-tools-aarch64-apple-darwin.zip` | |
| 287 | + | Windows | x86_64 | `mutation-tools-x86_64-windows.zip` | |
| 288 | +
|
| 289 | + ## Documentation |
| 290 | + For usage instructions and examples, visit: https://github.com/eigerco/move-mutation-tools |
| 291 | + draft: true |
| 292 | + prerelease: false |
| 293 | + files: release-assets/* |
| 294 | + fail_on_unmatched_files: true |
| 295 | + generate_release_notes: true |
0 commit comments