diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8f89b2aa4..6b40132b8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,7 +1,7 @@ name: CI on: - # Run on all pull requests and all pushes to master + #Run on all pull requests and all pushes to master push: branches: [ master ] pull_request: @@ -20,28 +20,114 @@ jobs: steps: - uses: actions/checkout@v2 - # TODO: cache all the setup - - name: Setup directories run: | # create directory that will be on the PATH mkdir -p ~/.local/bin echo "${HOME}/.local/bin" >> $GITHUB_PATH mkdir -p ~/source + + - uses: actions/cache@v2 + id: cache-gcc + with: + path: ~/gcc + key: ${{ runner.os }}-gcc + + - uses: actions/cache@v2 + id: cache-clang + with: + path: /usr/lib/llvm-5.0/bin/clang + key: ${{ runner.os }}-clang + + - uses: actions/cache@v2 + id: cache-clang-format + with: + path: /usr/bin/clang-format-5.0 + key: ${{ runner.os }}-clang-format + + - uses: actions/cache@v2 + id: cache-libc6-i386 + with: + path: /var/lib/dpkg/info/libc6-i386 + key: ${{ runner.os }}-libc6-i386 + + - uses: actions/cache@v2 + id: cache-linux-module + with: + path: /var/lib/dpkg/info/linux-modules-extra-4.15.0-20-generic + key: ${{ runner.os }}-linux-module - - name: Install gcc, clang, clang-format + - uses: actions/cache@v2 + id: cache-make + with: + path: /usr/bin/make + key: ${{ runner.os }}-make + + - uses: actions/cache@v2 + id: cache-pip + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + #path: $HOME/.cache/pip + + - uses: actions/cache@v2 + id: cache-arm-v1 + with: + path: $HOME/.arm-none-eabi-gcc-cache + key: ${{ runner.os }}-arm-v1 + + - name: Add repo and update run: | sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update - sudo apt-fast -y install gcc-6 - sudo apt-fast -y install clang-5.0 - sudo apt-fast -y install clang-format-5.0 - sudo apt-fast -y install libc6-i386 - # for vcan module - sudo apt-fast -y install linux-modules-extra-$(uname -r) + + - name: Install gcc + if: steps.cache-gcc.outputs.cache-hit != 'true' + run: sudo apt-fast -y install gcc-6 + + # - name: Install gcc + # env: + # CACHE_HIT: ${{steps.cache-gcc.outputs.cache-hit}} + # run: | + # if [[ "$CACHE_HIT" == 'true' ]]; then + # sudo cp --force --recursive ~/gcc/* / + # else + # sudo apt-fast -y install gcc-6 + # sudo dpkg -L gcc-6 | while IFS= read -r f; do if test -f $f; then echo $f; fi; done | xargs cp --parents --target-directory ~/gcc/ + # for dep in cpp-6 gcc-6-base gcc-8-base libasan3 libgcc-6-dev libmpx2; do + # dpkg -L $dep | while IFS= read -r f; do if test -f $f; then echo $f; fi; done | xargs cp --parents --target-directory ~/gcc/ + # done + # fi + + - name: Install clang + if: steps.cache-clang.outputs.cache-hit != 'true' + run: sudo apt-fast -y install clang-5.0 + + - name: Install clang-format + if: steps.cache-clang-format.outputs.cache-hit != 'true' + run: sudo apt-fast -y install clang-format-5.0 + + - name: Install libc6-i386 + if: steps.cache-libc6-i386.outputs.cache-hit != 'true' + run: sudo apt-fast -y install libc6-i386 + + # for vcan module + - name: Install linux modules + if: steps.cache-linux-module.outputs.cache-hit != 'true' + run: sudo apt-fast -y install linux-modules-extra-$(uname -r) + + - name: Which gcc, clang, clang-format + run: | ln -sf `which gcc-6` ~/.local/bin/gcc ln -sf `which clang-5.0` ~/.local/bin/clang ln -sf `which clang-format-5.0` ~/.local/bin/clang-format + + - name: Make arm cache directory + #run: + #mkdir -p /home/runner/.arm-none-eabi-gcc-cache + run: | + mkdir -p ~/.arm-none-eabi-gcc-cache + echo "${HOME}/.arm-none-eabi-gcc-cache" >> $GITHUB_PATH - name: Install STM32 toolchain env: @@ -60,6 +146,7 @@ jobs: python-version: '3.x' - name: Install Python tooling + if: steps.cache-pip.outputs.cache-hit != 'true' run: | pip install --user virtualenv pip install --upgrade pip @@ -84,11 +171,14 @@ jobs: clang-format --version .venv/bin/pip3 freeze - - name: Format and lint - run: | - make test_format - make lint - make pylint + - name: Format + run: make test_format + + - name: Lint + run: make lint + + - name: Pylint + run: make pylint - name: Build codegen run: | @@ -128,10 +218,14 @@ jobs: make build_all PLATFORM=stm32f0xx DEFINE="${DEFINES}" make clean - - name: Build and test - id: build-test - run: | - make build_all PLATFORM=x86 DEFINE="${DEFINES}" - make test_all PLATFORM=x86 DEFINE="${DEFINES}" - make pytest_all - make build_all PLATFORM=x86 COMPILER=clang DEFINE="${DEFINES}" + - name: Build x86 + run: make build_all PLATFORM=x86 DEFINE="${DEFINES}" + + - name: Test x86 + run: make test_all PLATFORM=x86 DEFINE="${DEFINES}" + + - name: Pytest + run: make pytest_all + + - name: Build x86 with clang + run: make build_all PLATFORM=x86 COMPILER=clang DEFINE="${DEFINES}"