|
| 1 | +name: Pull Request Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - develop |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - develop |
| 10 | + |
| 11 | +jobs: |
| 12 | + setup: |
| 13 | + name: Set up |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + outputs: |
| 17 | + tn: ${{ steps.parse.outputs.tn }} |
| 18 | + bld: ${{ steps.parse.outputs.bld }} |
| 19 | + test: ${{ steps.parse.outputs.test }} |
| 20 | + img: ${{ steps.parse.outputs.img }} |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout codes |
| 24 | + uses: actions/checkout@v2 |
| 25 | + |
| 26 | + - name: Parse cases |
| 27 | + id: parse |
| 28 | + run: | |
| 29 | + cd ${GITHUB_WORKSPACE}/tests/ci |
| 30 | + parsed_output=( $(./parse.sh) ) |
| 31 | + name_=${parsed_output[0]} |
| 32 | + bld_=${parsed_output[1]} |
| 33 | + test_=${parsed_output[2]} |
| 34 | + img_=${parsed_output[3]} |
| 35 | +
|
| 36 | + echo "::set-output name=tn::$name_" |
| 37 | + echo "::set-output name=bld::$bld_" |
| 38 | + echo "::set-output name=test::$test_" |
| 39 | + echo "::set-output name=img::$img_" |
| 40 | +
|
| 41 | + echo "test name : $name_" |
| 42 | + echo "build set : $bld_" |
| 43 | + echo "test set : $test_" |
| 44 | + echo "image name: $img_" |
| 45 | +
|
| 46 | + build: |
| 47 | + name: Build (${{ matrix.bld_set }}) |
| 48 | + needs: setup |
| 49 | + runs-on: ubuntu-latest |
| 50 | + |
| 51 | + strategy: |
| 52 | + fail-fast: false |
| 53 | + matrix: ${{ fromJson(needs.setup.outputs.bld) }} |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Checkout codes |
| 57 | + uses: actions/checkout@v2 |
| 58 | + with: |
| 59 | + submodules: recursive |
| 60 | + |
| 61 | + - name: Build |
| 62 | + run: | |
| 63 | + printf '{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json >/dev/null |
| 64 | + sudo systemctl restart docker |
| 65 | + sleep 10 |
| 66 | + cd tests/ci && ./ci.sh -n ${{ needs.setup.outputs.tn }} -b ${{ matrix.bld_set }} |
| 67 | +
|
| 68 | + - name: Free up disk space |
| 69 | + run: | |
| 70 | + sudo docker rmi $(sudo docker image ls | grep -E -m1 '<none>' | awk '{ print $3 }') |
| 71 | + sudo docker rmi $(sudo docker image ls | awk '/ci-test-base/ { print $3 }') |
| 72 | +
|
| 73 | + - name: Prepare artifacts |
| 74 | + run: | |
| 75 | + cd tests/ci |
| 76 | + sudo docker save ${{ needs.setup.outputs.img }} | gzip >${{ needs.setup.outputs.img }}.tar.gz |
| 77 | + tar cvjf artifact.tar.bz2 ${{ needs.setup.outputs.img }}.tar.gz ci.sh ci.test |
| 78 | +
|
| 79 | + - name: Upload artifacts |
| 80 | + uses: actions/upload-artifact@v2 |
| 81 | + with: |
| 82 | + name: ${{ matrix.bld_set }}.artifact.tar.bz2 |
| 83 | + path: tests/ci/artifact.tar.bz2 |
| 84 | + |
| 85 | + utest: |
| 86 | + name: Unit test (${{ needs.setup.outputs.tn }}, ${{ matrix.test_set }}) |
| 87 | + needs: [setup,build] |
| 88 | + runs-on: ubuntu-latest |
| 89 | + #runs-on: self-hosted |
| 90 | + |
| 91 | + strategy: |
| 92 | + fail-fast: false |
| 93 | + matrix: ${{ fromJson(needs.setup.outputs.test) }} |
| 94 | + |
| 95 | + steps: |
| 96 | + - name: Download artifacts |
| 97 | + uses: actions/download-artifact@v2 |
| 98 | + with: |
| 99 | + name: ${{ matrix.artifact }}.artifact.tar.bz2 |
| 100 | + |
| 101 | + - name: Prepare artifacts |
| 102 | + run: | |
| 103 | + tar xvjf artifact.tar.bz2 && rm -f artifact.tar.bz2 |
| 104 | + sudo docker load --input ${{ needs.setup.outputs.img }}.tar.gz && rm -f ${{ needs.setup.outputs.img }}.tar.gz |
| 105 | +
|
| 106 | + - name: Run utest |
| 107 | + run: ./ci.sh -n ${{ needs.setup.outputs.tn }} -r ${{ matrix.test_set }} |
| 108 | + |
| 109 | + - name: Upload memory usage file |
| 110 | + if: ${{ always() }} |
| 111 | + uses: actions/upload-artifact@v2 |
| 112 | + with: |
| 113 | + name: memory_stat_${{ matrix.test_set }} |
| 114 | + path: memory_stat |
| 115 | + |
| 116 | + - name: Clean up |
| 117 | + if: ${{ always() }} |
| 118 | + run: | |
| 119 | + rm -f ci.sh ci.test |
| 120 | + sudo docker rm my-container && sudo docker rmi ${{ needs.setup.outputs.img }}:latest |
| 121 | + sudo docker volume rm DataVolume |
0 commit comments