|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths-ignore: |
| 6 | + - '**.md' |
| 7 | + - 'docs/**' |
| 8 | + - '.gitignore' |
| 9 | + pull_request: |
| 10 | + branches: [master] |
| 11 | + workflow_call: |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + packages: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + lint: |
| 23 | + uses: ./.github/workflows/lint.yml |
| 24 | + |
| 25 | + unit-tests: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + timeout-minutes: 20 |
| 28 | + steps: |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@v6.0.1 |
| 31 | + |
| 32 | + - name: Set up Go |
| 33 | + uses: ./.github/actions/setup-go |
| 34 | + |
| 35 | + - name: Install dependencies |
| 36 | + run: go mod download |
| 37 | + |
| 38 | + - name: Run unit tests |
| 39 | + run: go test ./x/... -v |
| 40 | + |
| 41 | + integration-tests: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + timeout-minutes: 20 |
| 44 | + steps: |
| 45 | + - name: Checkout code |
| 46 | + uses: actions/checkout@v6.0.1 |
| 47 | + |
| 48 | + - name: Set up Go |
| 49 | + uses: ./.github/actions/setup-go |
| 50 | + |
| 51 | + - name: Install dependencies |
| 52 | + run: go mod download |
| 53 | + |
| 54 | + - name: Run integration tests |
| 55 | + run: go test -tags=integration,test -p 4 ./tests/integration/... -v |
| 56 | + |
| 57 | + system-tests: |
| 58 | + runs-on: ubuntu-latest |
| 59 | + timeout-minutes: 25 |
| 60 | + steps: |
| 61 | + - name: Checkout repository |
| 62 | + uses: actions/checkout@v6.0.1 |
| 63 | + with: |
| 64 | + fetch-depth: 0 |
| 65 | + |
| 66 | + - name: Configure Git Safe Directory |
| 67 | + uses: ./.github/actions/configure-git |
| 68 | + |
| 69 | + - name: Set up Go |
| 70 | + uses: ./.github/actions/setup-go |
| 71 | + |
| 72 | + - name: Install Ignite CLI |
| 73 | + uses: ./.github/actions/install-ignite |
| 74 | + |
| 75 | + - name: Build Chain |
| 76 | + run: ./ignite chain build -y -t linux:amd64 |
| 77 | + env: |
| 78 | + DO_NOT_TRACK: 1 |
| 79 | + GOFLAGS: "-buildvcs=false" |
| 80 | + |
| 81 | + - name: Prepare System Tests |
| 82 | + run: go mod tidy |
| 83 | + working-directory: tests/systemtests |
| 84 | + |
| 85 | + - name: Run System Tests |
| 86 | + run: go test -tags=system_test -timeout 20m -v . |
| 87 | + working-directory: tests/systemtests |
| 88 | + |
| 89 | + build: |
| 90 | + needs: [lint, unit-tests, integration-tests, system-tests] |
| 91 | + runs-on: ubuntu-latest |
| 92 | + timeout-minutes: 30 |
| 93 | + |
| 94 | + steps: |
| 95 | + - name: Checkout repository |
| 96 | + uses: actions/checkout@v6.0.1 |
| 97 | + with: |
| 98 | + fetch-depth: 0 |
| 99 | + |
| 100 | + - name: Configure Git Safe Directory |
| 101 | + uses: ./.github/actions/configure-git |
| 102 | + |
| 103 | + - name: Setup Go |
| 104 | + id: setup-go |
| 105 | + uses: ./.github/actions/setup-go |
| 106 | + |
| 107 | + - name: Prepare Build Variables |
| 108 | + id: vars |
| 109 | + run: | |
| 110 | + set -euo pipefail |
| 111 | +
|
| 112 | + repo_name=${GITHUB_REPOSITORY##*/} |
| 113 | +
|
| 114 | + build_id=${GITHUB_SHA::7} |
| 115 | + is_tag=false |
| 116 | +
|
| 117 | + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then |
| 118 | + build_id="${GITHUB_REF#refs/tags/}" |
| 119 | + is_tag=true |
| 120 | + fi |
| 121 | +
|
| 122 | + tarball_prefix="${repo_name}_${build_id}" |
| 123 | +
|
| 124 | + echo "build_id=$build_id" >> $GITHUB_OUTPUT |
| 125 | + echo "tarball_prefix=${tarball_prefix}" >> $GITHUB_OUTPUT |
| 126 | + echo "is_tag=${is_tag}" >> $GITHUB_OUTPUT |
| 127 | +
|
| 128 | + - name: Install Ignite CLI |
| 129 | + uses: ./.github/actions/install-ignite |
| 130 | + |
| 131 | + - name: Install wasmvm library |
| 132 | + uses: ./.github/actions/install-wasmvm |
| 133 | + |
| 134 | + - name: Install buf CLI |
| 135 | + run: | |
| 136 | + set -euo pipefail |
| 137 | + BUF_VERSION="$(go list -m -f '{{.Version}}' github.com/bufbuild/buf)" |
| 138 | + if [ -z "${BUF_VERSION}" ]; then |
| 139 | + echo "Failed to resolve github.com/bufbuild/buf version from go.mod" >&2 |
| 140 | + exit 1 |
| 141 | + fi |
| 142 | + go install "github.com/bufbuild/buf/cmd/buf@${BUF_VERSION}" |
| 143 | +
|
| 144 | + - name: Build with Ignite CLI |
| 145 | + run: | |
| 146 | + buf --version |
| 147 | + buf generate --template proto/buf.gen.gogo.yaml --verbose |
| 148 | + buf generate --template proto/buf.gen.swagger.yaml --verbose |
| 149 | + ./ignite version |
| 150 | + ./ignite generate openapi --yes |
| 151 | + ./ignite chain build --clear-cache --skip-proto --release --release.prefix ${{ steps.vars.outputs.tarball_prefix }} -y -t linux:amd64 |
| 152 | + env: |
| 153 | + DO_NOT_TRACK: 1 |
| 154 | + GOFLAGS: "-trimpath -buildvcs=false" |
| 155 | + CGO_LDFLAGS: "-Wl,-rpath,/usr/lib -Wl,--disable-new-dtags" |
| 156 | + |
| 157 | + - name: Fix Release Directory Permissions |
| 158 | + run: | |
| 159 | + sudo chown -R $USER:$USER release/ |
| 160 | + sudo chmod -R 755 release/ |
| 161 | +
|
| 162 | + - name: Package Release Artifacts |
| 163 | + run: | |
| 164 | + cd release |
| 165 | +
|
| 166 | + tar_file=$(ls *.tar.gz) |
| 167 | +
|
| 168 | + file_path=$(tar -tzf "$tar_file" | head -n 2 | grep -v '/$' | grep lumerad | sed 's|^/||') |
| 169 | + echo "Binary: $file_path" |
| 170 | + tar xzf "$tar_file" -C . |
| 171 | + ls -l "$file_path" |
| 172 | +
|
| 173 | + mkdir -p temp |
| 174 | + mv "$file_path" temp/ |
| 175 | + ls -l temp/ |
| 176 | +
|
| 177 | + rm "$tar_file" |
| 178 | +
|
| 179 | + cp /usr/lib/libwasmvm.x86_64.so temp/ |
| 180 | +
|
| 181 | + cat > temp/install.sh << 'EOF' |
| 182 | + #!/bin/bash |
| 183 | + if [ "$EUID" -ne 0 ]; then |
| 184 | + echo "Please run as root or with sudo" |
| 185 | + exit 1 |
| 186 | + fi |
| 187 | + cp lumerad /usr/local/bin |
| 188 | + cp libwasmvm.x86_64.so /usr/lib/ |
| 189 | + ldconfig |
| 190 | + echo "WASM library installed successfully" |
| 191 | + EOF |
| 192 | +
|
| 193 | + chmod +x temp/install.sh |
| 194 | +
|
| 195 | + cd temp |
| 196 | + tar czf "../$tar_file" ./* |
| 197 | + cd .. |
| 198 | +
|
| 199 | + rm -rf temp |
| 200 | +
|
| 201 | + tar tvf "$tar_file" |
| 202 | +
|
| 203 | + sha256sum "$tar_file" > release_checksum |
| 204 | +
|
| 205 | + - name: Upload Release Artifacts |
| 206 | + if: ${{ github.actor != 'nektos/act' }} |
| 207 | + uses: actions/upload-artifact@v4 |
| 208 | + with: |
| 209 | + name: release-artifacts |
| 210 | + path: release |
| 211 | + if-no-files-found: error |
0 commit comments