|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths-ignore: |
| 7 | + - "**.md" |
| 8 | + - "docs/**" |
| 9 | + - "LICENSE" |
| 10 | + pull_request: |
| 11 | + branches: [main] |
| 12 | + paths-ignore: |
| 13 | + - "**.md" |
| 14 | + - "docs/**" |
| 15 | + - "LICENSE" |
| 16 | + |
| 17 | +permissions: {} |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: ci-${{ github.ref }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +env: |
| 24 | + CARGO_TERM_COLOR: always |
| 25 | + RUSTFLAGS: -Dwarnings |
| 26 | + |
| 27 | +jobs: |
| 28 | + check: |
| 29 | + name: Check |
| 30 | + runs-on: ubuntu-latest |
| 31 | + permissions: |
| 32 | + contents: read # checkout |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 35 | + with: |
| 36 | + persist-credentials: false |
| 37 | + - run: rustup toolchain install stable --profile minimal |
| 38 | + - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 |
| 39 | + - run: cargo check --workspace --all-targets --all-features --locked |
| 40 | + |
| 41 | + fmt: |
| 42 | + name: Format |
| 43 | + runs-on: ubuntu-latest |
| 44 | + permissions: |
| 45 | + contents: read # checkout |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 48 | + with: |
| 49 | + persist-credentials: false |
| 50 | + - run: rustup toolchain install stable --profile minimal --component rustfmt |
| 51 | + - run: cargo fmt --all -- --check |
| 52 | + |
| 53 | + clippy: |
| 54 | + name: Clippy |
| 55 | + runs-on: ubuntu-latest |
| 56 | + permissions: |
| 57 | + contents: read # checkout |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 60 | + with: |
| 61 | + persist-credentials: false |
| 62 | + - run: rustup toolchain install stable --profile minimal --component clippy |
| 63 | + - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 |
| 64 | + - run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings |
| 65 | + |
| 66 | + test-rust: |
| 67 | + name: Test Rust (${{ matrix.os }}) |
| 68 | + runs-on: ${{ matrix.os }} |
| 69 | + strategy: |
| 70 | + fail-fast: false |
| 71 | + matrix: |
| 72 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 73 | + permissions: |
| 74 | + contents: read # checkout |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 77 | + with: |
| 78 | + persist-credentials: false |
| 79 | + - run: rustup toolchain install stable --profile minimal |
| 80 | + - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 |
| 81 | + - run: cargo test --workspace --all-features --locked |
| 82 | + |
| 83 | + build-wasm: |
| 84 | + name: Build WASM |
| 85 | + runs-on: ubuntu-latest |
| 86 | + permissions: |
| 87 | + contents: write # push updated core.wasm |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 90 | + with: |
| 91 | + ref: ${{ github.head_ref || github.ref_name }} |
| 92 | + persist-credentials: true # needed for git push in commit step |
| 93 | + - run: rustup toolchain install stable --profile minimal --target wasm32-wasip1 |
| 94 | + - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 |
| 95 | + - name: Install wasm-opt |
| 96 | + run: | |
| 97 | + curl -fsSL https://github.com/WebAssembly/binaryen/releases/download/version_129/binaryen-version_129-x86_64-linux.tar.gz \ |
| 98 | + | sudo tar -xz -C /usr/local --strip-components=1 |
| 99 | + - name: Install wasm-tools |
| 100 | + run: cargo install wasm-tools --locked |
| 101 | + - name: Rebuild core.wasm |
| 102 | + run: bash go/ressrf/build_wasm.sh |
| 103 | + - name: Commit if changed |
| 104 | + run: | |
| 105 | + if git diff --quiet go/ressrf/core.wasm; then |
| 106 | + echo "core.wasm is up to date" |
| 107 | + else |
| 108 | + git config user.name "github-actions[bot]" |
| 109 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 110 | + git add go/ressrf/core.wasm |
| 111 | + git commit -m "chore: rebuild core.wasm [ci]" |
| 112 | + git push |
| 113 | + fi |
| 114 | +
|
| 115 | + test-go: |
| 116 | + needs: [build-wasm] |
| 117 | + name: Test Go (${{ matrix.os }}) |
| 118 | + runs-on: ${{ matrix.os }} |
| 119 | + strategy: |
| 120 | + fail-fast: false |
| 121 | + matrix: |
| 122 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 123 | + permissions: |
| 124 | + contents: read # checkout |
| 125 | + steps: |
| 126 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 127 | + with: |
| 128 | + ref: ${{ github.head_ref || github.ref_name }} |
| 129 | + persist-credentials: false |
| 130 | + - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v6.0.2 |
| 131 | + with: |
| 132 | + go-version-file: go/ressrf/go.mod |
| 133 | + cache-dependency-path: go/ressrf/go.sum |
| 134 | + - name: Test |
| 135 | + working-directory: go/ressrf |
| 136 | + run: go test -count=1 -race ./... |
| 137 | + - name: Vet |
| 138 | + working-directory: go/ressrf |
| 139 | + run: go vet ./... |
| 140 | + |
| 141 | + lint-go: |
| 142 | + needs: [build-wasm] |
| 143 | + name: Lint Go |
| 144 | + runs-on: ubuntu-latest |
| 145 | + permissions: |
| 146 | + contents: read # checkout |
| 147 | + steps: |
| 148 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 149 | + with: |
| 150 | + ref: ${{ github.head_ref || github.ref_name }} |
| 151 | + persist-credentials: false |
| 152 | + - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v6.0.2 |
| 153 | + with: |
| 154 | + go-version-file: go/ressrf/go.mod |
| 155 | + cache-dependency-path: go/ressrf/go.sum |
| 156 | + - uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0 |
| 157 | + with: |
| 158 | + version: latest |
| 159 | + working-directory: go/ressrf |
0 commit comments