|
| 1 | +# Continuous integration and pull request validation builds for the |
| 2 | +# master and maintenance branches. |
| 3 | +name: CI Build |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: [ master, maint/* ] |
| 8 | + pull_request: |
| 9 | + branches: [ master, maint/* ] |
| 10 | + |
| 11 | +env: |
| 12 | + docker-registry: docker.pkg.github.com |
| 13 | + docker-config-path: azure-pipelines/docker |
| 14 | + |
| 15 | +jobs: |
| 16 | + # Build the docker container images that we will use for our Linux |
| 17 | + # builds. This will identify the last commit to the repository that |
| 18 | + # updated the docker images, and try to download the image tagged with |
| 19 | + # that sha. If it does not exist, we'll do a docker build and push |
| 20 | + # the image up to GitHub Packages for the actual CI/CD runs. We tag |
| 21 | + # with both the sha and "latest" so that the subsequent runs need not |
| 22 | + # know the sha. Only do this on CI builds (when the event is a "push") |
| 23 | + # because PR builds from forks lack permission to write packages. |
| 24 | + build_containers: |
| 25 | + name: Create docker image |
| 26 | + strategy: |
| 27 | + matrix: |
| 28 | + container: |
| 29 | + - xenial |
| 30 | + - bionic |
| 31 | + - docurium |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - name: Check out repository |
| 35 | + uses: actions/checkout@v2 |
| 36 | + with: |
| 37 | + fetch-depth: 0 |
| 38 | + if: github.event_name == 'push' |
| 39 | + - name: Download existing container |
| 40 | + run: azure-pipelines/getcontainer.sh ${{ env.docker-config-path }}/${{ matrix.container }} |
| 41 | + env: |
| 42 | + DOCKER_REGISTRY: ${{ env.docker-registry }} |
| 43 | + GITHUB_TOKEN: ${{ secrets.github_token }} |
| 44 | + if: github.event_name == 'push' |
| 45 | + - name: Build and publish image |
| 46 | + run: | |
| 47 | + docker build -t ${{ env.docker-registry-container-sha }} --build-arg BASE=${{ matrix.container.base }} -f ${{ matrix.container }} . |
| 48 | + docker push ${{ env.docker-registry-container-sha }} |
| 49 | + working-directory: ${{ env.docker-config-path }} |
| 50 | + if: github.event_name == 'push' && env.docker-container-exists != 'true' |
| 51 | + |
| 52 | + # Run our CI/CD builds. We build a matrix with the various build targets |
| 53 | + # and their details. Then we build either in a docker container (Linux) |
| 54 | + # or on the actual hosts (macOS, Windows). |
| 55 | + build: |
| 56 | + name: Build |
| 57 | + needs: [build_containers] |
| 58 | + strategy: |
| 59 | + matrix: |
| 60 | + platform: |
| 61 | + - # Xenial, GCC, OpenSSL |
| 62 | + image: xenial |
| 63 | + env: |
| 64 | + CC: gcc |
| 65 | + CMAKE_GENERATOR: Ninja |
| 66 | + CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON |
| 67 | + os: ubuntu-latest |
| 68 | + - # Xenial, GCC, mbedTLS |
| 69 | + image: xenial |
| 70 | + env: |
| 71 | + CC: gcc |
| 72 | + CMAKE_GENERATOR: Ninja |
| 73 | + CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON |
| 74 | + os: ubuntu-latest |
| 75 | + - # Xenial, Clang, OpenSSL |
| 76 | + image: xenial |
| 77 | + env: |
| 78 | + CC: clang |
| 79 | + CMAKE_GENERATOR: Ninja |
| 80 | + CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON |
| 81 | + os: ubuntu-latest |
| 82 | + - # Xenial, Clang, mbedTLS |
| 83 | + image: xenial |
| 84 | + env: |
| 85 | + CC: clang |
| 86 | + CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON |
| 87 | + CMAKE_GENERATOR: Ninja |
| 88 | + os: ubuntu-latest |
| 89 | + - # macOS |
| 90 | + os: macos-10.15 |
| 91 | + env: |
| 92 | + CC: clang |
| 93 | + CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks -DUSE_GSSAPI=ON |
| 94 | + CMAKE_GENERATOR: Ninja |
| 95 | + PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig |
| 96 | + SKIP_SSH_TESTS: true |
| 97 | + SKIP_NEGOTIATE_TESTS: true |
| 98 | + setup-script: osx |
| 99 | + - # Windows amd64 Visual Studio |
| 100 | + os: windows-2019 |
| 101 | + env: |
| 102 | + ARCH: amd64 |
| 103 | + CMAKE_GENERATOR: Visual Studio 16 2019 |
| 104 | + CMAKE_OPTIONS: -A x64 -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON |
| 105 | + SKIP_SSH_TESTS: true |
| 106 | + SKIP_NEGOTIATE_TESTS: true |
| 107 | + - # Windows x86 Visual Studio |
| 108 | + os: windows-2019 |
| 109 | + env: |
| 110 | + ARCH: x86 |
| 111 | + CMAKE_GENERATOR: Visual Studio 16 2019 |
| 112 | + CMAKE_OPTIONS: -A Win32 -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON |
| 113 | + SKIP_SSH_TESTS: true |
| 114 | + SKIP_NEGOTIATE_TESTS: true |
| 115 | + - # Windows amd64 mingw |
| 116 | + os: windows-2019 |
| 117 | + setup-script: mingw |
| 118 | + env: |
| 119 | + ARCH: amd64 |
| 120 | + CMAKE_GENERATOR: MinGW Makefiles |
| 121 | + CMAKE_OPTIONS: -DDEPRECATE_HARD=ON |
| 122 | + BUILD_TEMP: D:\Temp |
| 123 | + BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin |
| 124 | + SKIP_SSH_TESTS: true |
| 125 | + SKIP_NEGOTIATE_TESTS: true |
| 126 | + - # Windows x86 mingw |
| 127 | + os: windows-2019 |
| 128 | + setup-script: mingw |
| 129 | + env: |
| 130 | + ARCH: x86 |
| 131 | + CMAKE_GENERATOR: MinGW Makefiles |
| 132 | + CMAKE_OPTIONS: -DDEPRECATE_HARD=ON |
| 133 | + BUILD_TEMP: D:\Temp |
| 134 | + BUILD_PATH: D:\Temp\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin |
| 135 | + SKIP_SSH_TESTS: true |
| 136 | + SKIP_NEGOTIATE_TESTS: true |
| 137 | + fail-fast: false |
| 138 | + env: ${{ matrix.platform.env }} |
| 139 | + runs-on: ${{ matrix.platform.os }} |
| 140 | + steps: |
| 141 | + - name: Check out repository |
| 142 | + uses: actions/checkout@v2 |
| 143 | + with: |
| 144 | + fetch-depth: 0 |
| 145 | + - name: Set up build environment |
| 146 | + run: azure-pipelines/setup-${{ matrix.platform.setup-script }}.sh |
| 147 | + shell: bash |
| 148 | + if: matrix.platform.setup-script != '' |
| 149 | + - name: Download container |
| 150 | + run: azure-pipelines/getcontainer.sh ${{ env.docker-config-path }}/${{ matrix.platform.image }} |
| 151 | + env: |
| 152 | + DOCKER_REGISTRY: ${{ env.docker-registry }} |
| 153 | + GITHUB_TOKEN: ${{ secrets.github_token }} |
| 154 | + if: matrix.platform.image != '' |
| 155 | + - name: Create container |
| 156 | + run: docker build -t ${{ env.docker-registry-container-sha }} -f ${{ matrix.platform.image }} . |
| 157 | + working-directory: ${{ env.docker-config-path }} |
| 158 | + if: matrix.platform.image != '' && env.docker-container-exists != 'true' |
| 159 | + - name: Build and test |
| 160 | + run: | |
| 161 | + export GITTEST_NEGOTIATE_PASSWORD="${{ secrets.GITTEST_NEGOTIATE_PASSWORD }}" |
| 162 | +
|
| 163 | + if [ -n "${{ matrix.platform.image }}" ]; then |
| 164 | + docker run -v $(pwd):/home/libgit2/source -w /home/libgit2/source -e CC -e CMAKE_GENERATOR -e CMAKE_OPTIONS -e PKG_CONFIG_PATH -e GITTEST_NEGOTIATE_PASSWORD -e SKIP_SSH_TESTS -e SKIP_NEGOTIATE_TESTS ${{ env.docker-registry-container-sha }} /bin/bash -c "mkdir build && cd build && ../azure-pipelines/build.sh && ../azure-pipelines/test.sh" |
| 165 | + else |
| 166 | + mkdir build && cd build |
| 167 | + ../azure-pipelines/build.sh |
| 168 | + ../azure-pipelines/test.sh |
| 169 | + fi |
| 170 | + shell: bash |
| 171 | + |
| 172 | + # Generate documentation using docurium. We'll upload the documentation |
| 173 | + # as a build artifact so that it can be reviewed as part of a pull |
| 174 | + # request or in a forked build. For CI builds in the main repository's |
| 175 | + # master branch, we'll push the gh-pages branch back up so that it is |
| 176 | + # published to our documentation site. |
| 177 | + documentation: |
| 178 | + name: Generate documentation |
| 179 | + needs: [build_containers] |
| 180 | + runs-on: ubuntu-latest |
| 181 | + steps: |
| 182 | + - name: Check out repository |
| 183 | + uses: actions/checkout@v2 |
| 184 | + with: |
| 185 | + fetch-depth: 0 |
| 186 | + - name: Generate documentation |
| 187 | + run: | |
| 188 | + git config user.name 'Documentation Generation' |
| 189 | + git config user.email 'libgit2@users.noreply.github.com' |
| 190 | + git branch gh-pages origin/gh-pages |
| 191 | + docker login https://${{ env.docker-registry }} -u ${{ github.actor }} -p ${{ github.token }} |
| 192 | + docker run --rm -v $(pwd):/home/libgit2/source -w /home/libgit2/source ${{ env.docker-registry }}/${{ github.repository }}/docurium:latest cm doc api.docurium |
| 193 | + git checkout gh-pages |
| 194 | + zip --exclude .git/\* --exclude .gitignore --exclude .gitattributes -r api-documentation.zip . |
| 195 | + - uses: actions/upload-artifact@v2 |
| 196 | + name: Upload artifact |
| 197 | + with: |
| 198 | + name: api-documentation |
| 199 | + path: api-documentation.zip |
| 200 | + - name: Push documentation branch |
| 201 | + run: git push origin gh-pages |
| 202 | + if: github.event_name == 'push' && github.repository == 'libgit2/libgit2' |
0 commit comments