|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request_target: |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + packages: write |
| 10 | + |
| 11 | +env: |
| 12 | + DOCKER_DRIVER: overlay2 |
| 13 | + FAST_MODE: false |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-image: |
| 17 | + name: Build Image |
| 18 | + runs-on: ubuntu-20.04 |
| 19 | + outputs: |
| 20 | + image-tag: ${{ steps.prepare.outputs.image-tag }} |
| 21 | + repo-name: ${{ steps.prepare.outputs.repo-name }} |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Prepare |
| 27 | + id: prepare |
| 28 | + run: | |
| 29 | + BRANCH_NAME=$(echo "${GITHUB_REF##*/}" | tr '[:upper:]' '[:lower:]') |
| 30 | + REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') |
| 31 | + echo "::set-output name=image-tag::${BRANCH_NAME}" |
| 32 | + echo "::set-output name=repo-name::${REPO_NAME}" |
| 33 | +
|
| 34 | + - name: Set up Docker Buildx |
| 35 | + uses: docker/setup-buildx-action@v3 |
| 36 | + |
| 37 | + - name: Login to GitHub Container Registry |
| 38 | + uses: docker/login-action@v3 |
| 39 | + with: |
| 40 | + registry: ghcr.io |
| 41 | + username: ${{ github.actor }} |
| 42 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + |
| 44 | + - name: Build and push Docker image |
| 45 | + uses: docker/build-push-action@v6 |
| 46 | + with: |
| 47 | + context: ./contrib/containers/ci |
| 48 | + file: ./contrib/containers/ci/Dockerfile |
| 49 | + push: true |
| 50 | + tags: | |
| 51 | + ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-ci-runner:${{ steps.prepare.outputs.image-tag }} |
| 52 | + ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-ci-runner:latest |
| 53 | + cache-from: type=registry,ref=ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-ci-runner:latest |
| 54 | + cache-to: type=inline |
| 55 | + |
| 56 | + build-depends: |
| 57 | + name: Build Dependencies |
| 58 | + needs: build-image |
| 59 | + runs-on: ubuntu-20.04 |
| 60 | + strategy: |
| 61 | + matrix: |
| 62 | + include: |
| 63 | + - build_target: arm-linux |
| 64 | + host: arm-linux-gnueabihf |
| 65 | + container: |
| 66 | + image: ghcr.io/${{ needs.build-image.outputs.repo-name }}/dashcore-ci-runner:${{ needs.build-image.outputs.image-tag }} |
| 67 | + options: --user root |
| 68 | + steps: |
| 69 | + - name: Checkout code |
| 70 | + uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - name: Cache dependencies |
| 73 | + uses: actions/cache@v4 |
| 74 | + with: |
| 75 | + path: | |
| 76 | + depends/built |
| 77 | + depends/${{ matrix.host }} |
| 78 | + depends/sdk-sources |
| 79 | + # We don't care about no specific key as depends system will handle that for us |
| 80 | + key: ${{ runner.os }}-depends-${{ matrix.host }}-${{ github.sha }} |
| 81 | + restore-keys: | |
| 82 | + ${{ runner.os }}-depends-${{ matrix.host }}-${{ github.sha }} |
| 83 | + ${{ runner.os }}-depends-${{ matrix.host }} |
| 84 | + ${{ runner.os }}-depends |
| 85 | +
|
| 86 | + - name: Build dependencies |
| 87 | + run: make -j$(nproc) -C depends HOST=${{ matrix.host }} |
| 88 | + |
| 89 | + build: |
| 90 | + name: Build |
| 91 | + needs: [build-image, build-depends] |
| 92 | + runs-on: ubuntu-20.04 |
| 93 | + strategy: |
| 94 | + matrix: |
| 95 | + include: |
| 96 | + - build_target: arm-linux |
| 97 | + host: arm-linux-gnueabihf |
| 98 | + dep_opts: DEBUG=1 |
| 99 | + container: |
| 100 | + image: ghcr.io/${{ needs.build-image.outputs.repo-name }}/dashcore-ci-runner:${{ needs.build-image.outputs.image-tag }} |
| 101 | + options: --user root |
| 102 | + steps: |
| 103 | + - name: Checkout code |
| 104 | + uses: actions/checkout@v4 |
| 105 | + |
| 106 | + - name: Restore Cache dependencies |
| 107 | + uses: actions/cache/restore@v4 |
| 108 | + with: |
| 109 | + path: | |
| 110 | + depends/built |
| 111 | + depends/${{ matrix.host }} |
| 112 | + depends/sdk-sources |
| 113 | + # We don't care about no specific key as depends system will handle that for us |
| 114 | + key: ${{ runner.os }}-depends-${{ matrix.host }}-${{ github.sha }} |
| 115 | + restore-keys: | |
| 116 | + ${{ runner.os }}-depends-${{ matrix.host }}-${{ github.sha }} |
| 117 | + ${{ runner.os }}-depends-${{ matrix.host }} |
| 118 | + ${{ runner.os }}-depends |
| 119 | +
|
| 120 | + - name: CCache |
| 121 | + uses: actions/cache@v4 |
| 122 | + with: |
| 123 | + path: | |
| 124 | + /cache |
| 125 | + key: ${{ runner.os }}-${{ matrix.host }}-${{ github.sha }} |
| 126 | + restore-keys: | |
| 127 | + ${{ runner.os }}-${{ matrix.host }}-${{ github.sha }} |
| 128 | + ${{ runner.os }}-${{ matrix.host }} |
| 129 | + ${{ runner.os }} |
| 130 | +
|
| 131 | + - name: Build source and run tests |
| 132 | + run: | |
| 133 | + git config --global --add safe.directory "$PWD" |
| 134 | + CCACHE_SIZE="400M" |
| 135 | + CACHE_DIR="/cache" |
| 136 | + mkdir /output |
| 137 | + BASE_OUTDIR="/output" |
| 138 | + BUILD_TARGET="${{ matrix.build_target }}" |
| 139 | + source ./ci/dash/matrix.sh |
| 140 | + ./ci/dash/build_src.sh |
| 141 | + ./ci/dash/test_unittests.sh |
| 142 | + shell: bash |
| 143 | + |
| 144 | + - name: Upload build artifacts |
| 145 | + uses: actions/upload-artifact@v4 |
| 146 | + with: |
| 147 | + name: build-artifacts |
| 148 | + path: | |
| 149 | + /output |
| 150 | +
|
| 151 | +
|
| 152 | +# Come back to this later and implement tests :) |
| 153 | +# test: |
| 154 | +# name: Test |
| 155 | +# needs: [build-image, build] |
| 156 | +# runs-on: ubuntu-20.04 |
| 157 | +# container: |
| 158 | +# image: ghcr.io/${{ needs.build-image.outputs.repo-name }}/dashcore-ci-runner:${{ needs.build-image.outputs.image-tag }} |
| 159 | +# options: --user root |
| 160 | +# steps: |
| 161 | +# - name: Checkout code |
| 162 | +# uses: actions/checkout@v4 |
| 163 | +# |
| 164 | +# - name: Download build artifacts |
| 165 | +# uses: actions/download-artifact@v4 |
| 166 | +# with: |
| 167 | +# name: build-artifacts |
| 168 | +# path: src/ |
| 169 | +# |
| 170 | +## - name: Setup environment |
| 171 | +## run: | |
| 172 | +## echo "BUILD_TARGET=${{ needs.build.matrix.build_target }}" |
| 173 | +## source ./ci/dash/matrix.sh |
| 174 | +# |
| 175 | +# - name: Run integration tests |
| 176 | +# run: ./ci/dash/test_integrationtests.sh --extended --exclude feature_pruning,feature_dbcrash |
0 commit comments