Преглед изворни кода

Merge pull request #853 from hyperledger-labs/cache

Cache LLVM on Mac builders
Sean Young пре 3 година
родитељ
комит
023d752c05

+ 4 - 0
.github/workflows/build-llvm.yml

@@ -91,6 +91,8 @@ jobs:
     - run: cmake --build . --target install
       working-directory: ./llvm-project/
     - run: tar Jcf ./llvm13.0-mac-arm.tar.xz ./llvm13.0/
+    - name: Cache LLVM
+      run: ${{ github.workspace }}/.github/workflows/llvm-cache.sh llvm13.0-mac-arm.tar.xz
     - name: Upload Release Asset
       id: upload-release-asset
       uses: actions/upload-release-asset@v1
@@ -119,6 +121,8 @@ jobs:
     - run: cmake --build . --target install
       working-directory: ./llvm-project/
     - run: tar Jcf ./llvm13.0-mac-intel.tar.xz ./llvm13.0/
+    - name: Cache LLVM
+      run: ${{ github.workspace }}/.github/workflows/llvm-cache.sh llvm13.0-mac-intel.tar.xz
     - name: Upload Release Asset
       id: upload-release-asset
       uses: actions/upload-release-asset@v1

+ 12 - 0
.github/workflows/llvm-cache.sh

@@ -0,0 +1,12 @@
+#!/bin/bash
+set -ex
+CACHE=/Users/hyp/cache
+FILE=$CACHE/$1
+if [ -f "$1" ]; then
+    cp $1 $FILE
+elif [ -f "$FILE" ]; then
+    cp $FILE .
+else
+    curl -L --output $FILE https://github.com/hyperledger-labs/solang/releases/download/v0.1.11/$1
+    cp $FILE .
+fi

+ 8 - 3
.github/workflows/release.yml

@@ -137,7 +137,7 @@ jobs:
     if: ${{ github.repository_owner == 'hyperledger-labs' }}
     steps:
     - name: Checkout sources
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
     - run: git clone --depth 1 --branch solana-rustc/13.0-2021-08-08 https://github.com/solana-labs/llvm-project.git
     - name: Install Ninja
       uses: llvm/actions/install-ninja@main
@@ -150,6 +150,8 @@ jobs:
     - run: cmake --build . --target install
       working-directory: ./llvm-project/
     - run: tar Jcf ./llvm13.0-mac-arm.tar.xz ./llvm13.0/
+    - name: Cache LLVM
+      run: ${{ github.workspace }}/.github/workflows/llvm-cache.sh llvm13.0-mac-arm.tar.xz
     - name: Upload llvm
       uses: svenstaro/upload-release-action@v2
       with:
@@ -179,7 +181,7 @@ jobs:
     runs-on: macos-11
     steps:
     - name: Checkout sources
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
     - run: git clone --depth 1 --branch solana-rustc/13.0-2021-08-08 https://github.com/solana-labs/llvm-project.git
     - name: Install Ninja
       uses: llvm/actions/install-ninja@main
@@ -192,6 +194,8 @@ jobs:
     - run: cmake --build . --target install
       working-directory: ./llvm-project/
     - run: tar Jcf ./llvm13.0-mac-intel.tar.xz ./llvm13.0/
+    - name: Cache LLVM
+      run: ${{ github.workspace }}/.github/workflows/llvm-cache.sh llvm13.0-mac-intel.tar.xz
     - name: Upload llvm
       uses: svenstaro/upload-release-action@v2
       with:
@@ -230,10 +234,11 @@ jobs:
   container-multiarch:
     name: Multiarch Container Image
     runs-on: macos-arm
+    needs: [mac-arm, mac-intel]
     if: ${{ github.repository_owner == 'hyperledger-labs' }}
     steps:
     - name: Checkout sources
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
     - run: |
         echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
         docker buildx build . --push \

+ 7 - 6
.github/workflows/test.yml

@@ -132,13 +132,13 @@ jobs:
     if: ${{ github.repository_owner == 'hyperledger-labs' }}
     steps:
     - name: Checkout sources
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
         # Make sure "git describe --tags" works for solang --version
         fetch-depth: 0
         submodules: recursive
-    - name: Download LLVM
-      run: curl -L --output llvm13.0-mac-arm.tar.xz https://github.com/hyperledger-labs/solang/releases/download/v0.1.11/llvm13.0-mac-arm.tar.xz
+    - name: Get LLVM
+      run: ${{ github.workspace }}/.github/workflows/llvm-cache.sh llvm13.0-mac-arm.tar.xz
     - name: Extract LLVM
       run: tar Jxf llvm13.0-mac-arm.tar.xz
     - name: Add LLVM to Path
@@ -162,8 +162,8 @@ jobs:
         # Make sure "git describe --tags" works for solang --version
         fetch-depth: 0
         submodules: recursive
-    - name: Download LLVM
-      run: wget -q -O llvm13.0-mac-intel.tar.xz https://github.com/hyperledger-labs/solang/releases/download/v0.1.11/llvm13.0-mac-intel.tar.xz
+    - name: Get LLVM
+      run: ${{ github.workspace }}/.github/workflows/llvm-cache.sh llvm13.0-mac-intel.tar.xz
     - name: Extract LLVM
       run: tar Jxf llvm13.0-mac-intel.tar.xz
     - name: Add LLVM to Path
@@ -180,10 +180,11 @@ jobs:
   image-multiarch:
     name: Multiarch Container Image
     runs-on: macos-arm
+    needs: [mac-arm, mac-intel]
     if: ${{ github.repository_owner == 'hyperledger-labs' }}
     steps:
     - name: Checkout sources
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
       with:
         # Make sure "git describe --tags" works for solang --version
         fetch-depth: 0