From f5da1680a1d49591f34cc09491a7428048733fbf Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Wed, 27 Nov 2019 11:42:19 +0000 Subject: [PATCH] GitHub Actions: Implement Caching This commit uses the GitHub Actions cache to ensure that the `rtf` binary can be re-used between runs if it hasn't changed. It also caches the linuxkit binaries for use in future stages. Signed-off-by: Dave Tucker --- .github/workflows/build.yml | 181 -------------------- .github/workflows/ci.yml | 322 ++++++++++++++++++++++++++++++++++++ 2 files changed, 322 insertions(+), 181 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 3304d918b..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,181 +0,0 @@ -name: LinuxKit CI -on: [push, pull_request] - -jobs: - build: - name: Build & Test - strategy: - matrix: - arch: - - amd64-linux - - arm64-linux - - s390x-linux - - amd64-darwin - - amd64-windows.exe - - runs-on: ubuntu-latest - steps: - - - name: Set up Go 1.11 - uses: actions/setup-go@v1 - with: - go-version: 1.11 - id: go - - - name: Check out code - uses: actions/checkout@v1 - with: - path: ./src/github.com/linuxkit/linuxkit - - - name: Get pre-requisites - run: | - echo "::set-env name=PATH::$PATH:$(go env GOPATH)/bin" - go get -u golang.org/x/lint/golint - go get -u github.com/gordonklaus/ineffassign - env: - GOPATH: ${{runner.workspace}} - - - name: Lint - run: | - make local-check - env: - GOPATH: ${{runner.workspace}} - - - name: Build - run: | - make LOCAL_TARGET=bin/linuxkit-${{matrix.arch}} local-build - env: - GOPATH: ${{runner.workspace}} - - - name: Checksum - run: cd bin && sha256sum linuxkit-${{matrix.arch}} > linuxkit-${{matrix.arch}}.SHA256SUM - - - name: Test - run: make local-test - env: - GOPATH: ${{runner.workspace}} - - - name: Upload binary - uses: actions/upload-artifact@v1.0.0 - with: - name: linuxkit-${{matrix.arch}} - path: bin - - build_packages: - name: Build Packages - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v1 - with: - path: ./src/github.com/linuxkit/linuxkit - - - name: Install Tools - run: | - make - sudo make install - - - name: Build Packages - run: | - make -C pkg build - - test_packages: - name: Packages Tests - needs: [ build_packages, build ] - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v1 - with: - path: ./src/github.com/linuxkit/linuxkit - - - name: Install Tools - run: | - DEBIAN_FRONTEND=noninteractive sudo apt-get install -qy expect - make - sudo make install - - - name: Run Tests - run: | - cd test - rtf -l build -v run -x linuxkit.packages - - test_kernel: - name: Kernel Tests - needs: build - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v1 - with: - path: ./src/github.com/linuxkit/linuxkit - - - name: Install Tools - run: | - make - sudo make install - - - name: Run Tests - run: | - cd test - rtf -l build -v run -x linuxkit.kernel - - test_linuxkit: - name: LinuxKit Build Tests - needs: build - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v1 - with: - path: ./src/github.com/linuxkit/linuxkit - - - name: Install Tools - run: | - make - sudo make install - - - name: Run Tests - run: | - cd test - rtf -l build -v run -x linuxkit.build - - test_platforms: - name: Platform Tests - needs: build - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v1 - with: - path: ./src/github.com/linuxkit/linuxkit - - - name: Install Tools - run: | - make - sudo make install - - - name: Run Tests - run: | - cd test - rtf -l build -v run -x linuxkit.platforms - - test_security: - name: Security Tests - needs: build - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v1 - with: - path: ./src/github.com/linuxkit/linuxkit - - - name: Install Tools - run: | - make - sudo make install - - - name: Run Tests - run: | - cd test - rtf -l build -v run -x linuxkit.security \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..f99569b65 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,322 @@ +name: LinuxKit CI +on: [push, pull_request] + +jobs: + build: + name: Build & Test + strategy: + matrix: + arch: + - amd64-linux + - arm64-linux + - s390x-linux + - amd64-darwin + - amd64-windows.exe + + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.11 + uses: actions/setup-go@v1 + with: + go-version: 1.11 + id: go + + - name: Check out code + uses: actions/checkout@v1 + with: + path: ./src/github.com/linuxkit/linuxkit + + - name: Get pre-requisites + run: | + echo "::set-env name=PATH::$PATH:$(go env GOPATH)/bin" + go get -u golang.org/x/lint/golint + go get -u github.com/gordonklaus/ineffassign + env: + GOPATH: ${{runner.workspace}} + + - name: Lint + run: | + make local-check + env: + GOPATH: ${{runner.workspace}} + + - name: Build + run: | + make LOCAL_TARGET=bin/linuxkit-${{matrix.arch}} local-build + env: + GOPATH: ${{runner.workspace}} + + - name: Checksum + run: cd bin && sha256sum linuxkit-${{matrix.arch}} > linuxkit-${{matrix.arch}}.SHA256SUM + + - name: Test + run: make local-test + env: + GOPATH: ${{runner.workspace}} + + - name: Cache binary + uses: actions/cache@v1 + with: + path: bin + key: linuxkit-${{matrix.arch}}-${{hashFiles('src/**')}} + + - name: Upload binary + uses: actions/upload-artifact@v1.0.0 + with: + name: linuxkit-${{matrix.arch}} + path: bin + + build_packages: + name: Build Packages + needs: build + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v1 + with: + path: ./src/github.com/linuxkit/linuxkit + + - name: Restore LinuxKit From Cache + uses: actions/cache@v1 + with: + path: lkt + key: linuxkit-amd64-linux-${{hashFiles('src/**')}} + + - name: Symlink Linuxkit + run: | + sudo ln -s `pwd`/lkt/linuxkit-amd64-linux /bin/linuxkit + + - name: Build Packages + run: | + make -C pkg build + + test_packages: + name: Packages Tests + needs: [ build_packages, build ] + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v1 + with: + path: ./src/github.com/linuxkit/linuxkit + + - name: Install Pre-Requisites + run: | + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update + sudo apt-get install -qy qemu-utils qemu-system-x86 expect + + - name: Restore RTF From Cache + id: cache-rtf + uses: actions/cache@v1 + with: + path: bin + key: rtf-${{hashFiles('Makefile')}} + + - name: Build RTF + if: steps.cache-rtf.outputs.cache-hit != 'true' + run: make bin/rtf + + - name: Symlink RTF + run: | + sudo ln -s `pwd`/bin/rtf /bin/rtf + + - name: Restore LinuxKit From Cache + uses: actions/cache@v1 + with: + path: lkt + key: linuxkit-amd64-linux-${{hashFiles('src/**')}} + + - name: Symlink Linuxkit + run: | + sudo ln -s `pwd`/lkt/linuxkit-amd64-linux /bin/linuxkit + + - name: Run Tests + run: | + cd test + rtf -l build -v run -x linuxkit.packages + + test_kernel: + name: Kernel Tests + needs: build + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v1 + with: + path: ./src/github.com/linuxkit/linuxkit + + - name: Install Pre-Requisites + run: | + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update + sudo apt-get install -qy qemu-utils qemu-system-x86 expect + + - name: Restore RTF From Cache + id: cache-rtf + uses: actions/cache@v1 + with: + path: bin + key: rtf-${{hashFiles('Makefile')}} + + - name: Build RTF + if: steps.cache-rtf.outputs.cache-hit != 'true' + run: make bin/rtf + + - name: Symlink RTF + run: | + sudo ln -s `pwd`/bin/rtf /bin/rtf + + - name: Restore LinuxKit From Cache + uses: actions/cache@v1 + with: + path: lkt + key: linuxkit-amd64-linux-${{hashFiles('src/**')}} + + - name: Symlink Linuxkit + run: | + sudo ln -s `pwd`/lkt/linuxkit-amd64-linux /bin/linuxkit + + - name: Run Tests + run: | + cd test + rtf -l build -v run -x linuxkit.kernel + + test_linuxkit: + name: LinuxKit Build Tests + needs: build + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v1 + with: + path: ./src/github.com/linuxkit/linuxkit + + - name: Install Pre-Requisites + run: | + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update + sudo apt-get install -qy qemu-utils qemu-system-x86 expect + + - name: Restore RTF From Cache + id: cache-rtf + uses: actions/cache@v1 + with: + path: bin + key: rtf-${{hashFiles('Makefile')}} + + - name: Build RTF + if: steps.cache-rtf.outputs.cache-hit != 'true' + run: make bin/rtf + + - name: Symlink RTF + run: | + sudo ln -s `pwd`/bin/rtf /bin/rtf + + - name: Restore LinuxKit From Cache + uses: actions/cache@v1 + with: + path: lkt + key: linuxkit-amd64-linux-${{hashFiles('src/**')}} + + - name: Symlink Linuxkit + run: | + sudo ln -s `pwd`/lkt/linuxkit-amd64-linux /bin/linuxkit + + - name: Run Tests + run: | + cd test + rtf -l build -v run -x linuxkit.build + + test_platforms: + name: Platform Tests + needs: build + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v1 + with: + path: ./src/github.com/linuxkit/linuxkit + + - name: Install Pre-Requisites + run: | + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update + sudo apt-get install -qy qemu-utils qemu-system-x86 expect + + - name: Restore RTF From Cache + id: cache-rtf + uses: actions/cache@v1 + with: + path: bin + key: rtf-${{hashFiles('Makefile')}} + + - name: Build RTF + if: steps.cache-rtf.outputs.cache-hit != 'true' + run: make bin/rtf + + - name: Symlink RTF + run: | + sudo ln -s `pwd`/bin/rtf /bin/rtf + + - name: Restore LinuxKit From Cache + uses: actions/cache@v1 + with: + path: lkt + key: linuxkit-amd64-linux-${{hashFiles('src/**')}} + + - name: Symlink Linuxkit + run: | + sudo ln -s `pwd`/lkt/linuxkit-amd64-linux /bin/linuxkit + + - name: Run Tests + run: | + cd test + rtf -l build -v run -x linuxkit.platforms + + test_security: + name: Security Tests + needs: build + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v1 + with: + path: ./src/github.com/linuxkit/linuxkit + + - name: Install Pre-Requisites + run: | + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update + sudo apt-get install -qy qemu-utils qemu-system-x86 expect + + - name: Restore RTF From Cache + id: cache-rtf + uses: actions/cache@v1 + with: + path: bin + key: rtf-${{hashFiles('Makefile')}} + + - name: Build RTF + if: steps.cache-rtf.outputs.cache-hit != 'true' + run: make bin/rtf + + - name: Symlink RTF + run: | + sudo ln -s `pwd`/bin/rtf /bin/rtf + + - name: Restore LinuxKit From Cache + uses: actions/cache@v1 + with: + path: lkt + key: linuxkit-amd64-linux-${{hashFiles('src/**')}} + + - name: Symlink Linuxkit + run: | + sudo ln -s `pwd`/lkt/linuxkit-amd64-linux /bin/linuxkit + + - name: Run Tests + run: | + cd test + rtf -l build -v run -x linuxkit.security \ No newline at end of file