|
| 1 | +name: Create-Cache |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run at 1:07 on mondays and fridays |
| 6 | + # https://stackoverflow.com/questions/59560214/github-action-works-on-push-but-not-scheduled |
| 7 | + - cron: 7 1 * * 1,5 |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +jobs: |
| 13 | + init-submodules: |
| 14 | + runs-on: ubuntu-20.04 |
| 15 | + defaults: |
| 16 | + run: |
| 17 | + working-directory: riscv-gnu-toolchain |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v3 |
| 21 | + |
| 22 | + - name: Setup env |
| 23 | + uses: ./.github/actions/common/setup-env |
| 24 | + with: |
| 25 | + free_up_space: false |
| 26 | + |
| 27 | + - name: Retrieve cache |
| 28 | + id: retrieve-cache |
| 29 | + uses: actions/cache@v3 |
| 30 | + with: |
| 31 | + path: | |
| 32 | + riscv-gnu-toolchain/.git |
| 33 | + riscv-gnu-toolchain/binutils |
| 34 | + riscv-gnu-toolchain/dejagnu |
| 35 | + riscv-gnu-toolchain/gcc |
| 36 | + riscv-gnu-toolchain/gdb |
| 37 | + riscv-gnu-toolchain/glibc |
| 38 | + riscv-gnu-toolchain/newlib |
| 39 | + riscv-gnu-toolchain/qemu |
| 40 | + key: submodules-archive-9 # Numbered archive to allow for easy transition when bumping submodules |
| 41 | + |
| 42 | + - name: Initalize submodules cache |
| 43 | + id: cache-init |
| 44 | + if: steps.retrieve-cache.outputs.cache-hit != 'true' |
| 45 | + run: | |
| 46 | + git submodule update --init --recursive --depth 1 binutils |
| 47 | + git submodule update --init --recursive --depth 1 dejagnu |
| 48 | + git submodule update --init --recursive --depth 1 gdb |
| 49 | + git submodule update --init --recursive --depth 1 glibc |
| 50 | + git submodule update --init --recursive --depth 1 newlib |
| 51 | + git submodule update --init --recursive --depth 1 qemu |
| 52 | + continue-on-error: true |
| 53 | + |
| 54 | + - name: Initalize submodules cache |
| 55 | + if: steps.cache-init.outcome == 'failure' |
| 56 | + run: | |
| 57 | + echo "Failed to initialize cache submodules. Retrying in 1 min" |
| 58 | + sleep 60 |
| 59 | + git submodule update --init --recursive --depth 1 binutils |
| 60 | + git submodule update --init --recursive --depth 1 dejagnu |
| 61 | + git submodule update --init --recursive --depth 1 gdb |
| 62 | + git submodule update --init --recursive --depth 1 glibc |
| 63 | + git submodule update --init --recursive --depth 1 newlib |
| 64 | + git submodule update --init --recursive --depth 1 qemu |
| 65 | +
|
| 66 | + - name: Initialize gcc |
| 67 | + if: steps.retrieve-cache.outputs.cache-hit != 'true' |
| 68 | + id: gcc-cache |
| 69 | + uses: ./.github/actions/common/init-and-pull-gcc |
| 70 | + with: |
| 71 | + init: true |
| 72 | + |
| 73 | + # Does not remove and reclone gcc if we hit cache |
| 74 | + - name: Checkout GCC |
| 75 | + if: steps.gcc-cache.outcome == 'skipped' |
| 76 | + uses: ./.github/actions/common/init-and-pull-gcc |
| 77 | + with: |
| 78 | + init: false |
| 79 | + |
| 80 | + - name: Apply newlib fixups |
| 81 | + if: steps.retrieve-cache.outputs.cache-hit != 'true' |
| 82 | + run: | |
| 83 | + cd newlib |
| 84 | + git config --global user.email "github-bot@example.com" |
| 85 | + git config --global user.name "Github Bot" |
| 86 | + git am ../fixups/newlib/*.patch |
| 87 | +
|
| 88 | + - name: Cache submodules |
| 89 | + if: steps.retrieve-cache.outputs.cache-hit != 'true' |
| 90 | + uses: actions/cache/save@v3 |
| 91 | + with: |
| 92 | + path: | |
| 93 | + riscv-gnu-toolchain/.git |
| 94 | + riscv-gnu-toolchain/binutils |
| 95 | + riscv-gnu-toolchain/dejagnu |
| 96 | + riscv-gnu-toolchain/gcc |
| 97 | + riscv-gnu-toolchain/gdb |
| 98 | + riscv-gnu-toolchain/glibc |
| 99 | + riscv-gnu-toolchain/newlib |
| 100 | + riscv-gnu-toolchain/qemu |
| 101 | + key: submodules-archive-9 |
| 102 | + |
| 103 | + - name: Make cache zip |
| 104 | + run: | |
| 105 | + zip -r cache.zip .git binutils dejagnu gcc gdb glibc newlib qemu |
| 106 | +
|
| 107 | + # Use artifact rather than cache since cache downloads are flaky/hang. |
| 108 | + # Artifacts are reliable but ~30 min slower to set up. |
| 109 | + # Setup is done on one runner, so this isn't a show stopper. |
| 110 | + - name: Upload git cache |
| 111 | + uses: actions/upload-artifact@v3 |
| 112 | + with: |
| 113 | + name: gcc-sources |
| 114 | + path: | |
| 115 | + riscv-gnu-toolchain/cache.zip |
| 116 | + retention-days: 5 |
| 117 | + |
0 commit comments