2
0
Kevin Leung 3 жил өмнө
parent
commit
9abd4a96d6
2 өөрчлөгдсөн 53 нэмэгдсэн , 10 устгасан
  1. 38 8
      .github/workflows/main.yml
  2. 15 2
      Earthfile

+ 38 - 8
.github/workflows/main.yml

@@ -233,7 +233,14 @@ jobs:
     runs-on: ubuntu-20.04
     env:
       OPAMYES: 1
-    steps:  
+    steps:
+      - name: Login to GitHub Container Registry
+        uses: docker/login-action@v1
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+          
       - name: Install Earthly
         run: sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/latest/download/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly && /usr/local/bin/earthly bootstrap --with-autocomplete'
         
@@ -246,7 +253,7 @@ jobs:
         run: echo "ADD_REVISION=1" >> $GITHUB_ENV
 
       - name: Build
-        run: earthly --platform=linux/amd64 +build --ADD_REVISION=$ADD_REVISION
+        run: earthly --platform=linux/amd64 --ci --remote-cache=ghcr.io/${{ github.repository }}:cache --push +build --ADD_REVISION=$ADD_REVISION
       
       - name: Upload artifact
         uses: actions/[email protected]
@@ -261,7 +268,7 @@ jobs:
         run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
       
       - name: Build xmldoc
-        run: earthly +xmldoc --COMMIT=$GITHUB_SHA --BRANCH=${{ steps.extract_branch.outputs.branch }}
+        run: earthly --ci --remote-cache=ghcr.io/${{ github.repository }}:cache --push +xmldoc --COMMIT=$GITHUB_SHA --BRANCH=${{ steps.extract_branch.outputs.branch }}
       
       - name: Upload xmldoc artifact
         uses: actions/[email protected]
@@ -274,6 +281,15 @@ jobs:
     env:
       OPAMYES: 1
     steps:
+      - name: Login to GitHub Container Registry
+        uses: docker/login-action@v1
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+          # https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
+          # github.repository_owner
+      
       - name: Set up QEMU
         id: qemu
         uses: docker/setup-qemu-action@v1
@@ -293,7 +309,7 @@ jobs:
         run: echo "ADD_REVISION=1" >> $GITHUB_ENV
 
       - name: Build
-        run: earthly --platform=linux/arm64 +build --ADD_REVISION=$ADD_REVISION
+        run: earthly --platform=linux/arm64 --ci --remote-cache=ghcr.io/${{ github.repository }}:cache --push +build --ADD_REVISION=$ADD_REVISION
       
       - name: Upload artifact
         uses: actions/[email protected]
@@ -616,6 +632,13 @@ jobs:
     strategy:
       fail-fast: false
     steps:
+      - name: Login to GitHub Container Registry
+        uses: docker/login-action@v1
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+          
       - uses: actions/checkout@main
         with:
           submodules: recursive
@@ -632,11 +655,11 @@ jobs:
       
       - name: Test
         if: success() && !(matrix.SAUCE && matrix.SAUCE_ACCESS_KEY)
-        run: earthly --platform=linux/amd64 +test-all
+        run: earthly --platform=linux/amd64 --ci --remote-cache=ghcr.io/${{ github.repository }}:cache --push +test-all
       
       - name: Test (with SauceLabs)
         if: success() && matrix.SAUCE && matrix.SAUCE_ACCESS_KEY
-        run: earthly --platform=linux/amd64 +test --TEST=js
+        run: earthly --platform=linux/amd64 --ci --remote-cache=ghcr.io/${{ github.repository }}:cache --push +test --TEST=js
         env:
           SAUCE_ACCESS_KEY: matrix.SAUCE_ACCESS_KEY
       
@@ -648,6 +671,13 @@ jobs:
     strategy:
       fail-fast: false
     steps:
+      - name: Login to GitHub Container Registry
+        uses: docker/login-action@v1
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+          
       - uses: actions/checkout@main
         with:
           submodules: recursive
@@ -664,11 +694,11 @@ jobs:
       
       - name: Test
         if: success() && !(matrix.SAUCE && matrix.SAUCE_ACCESS_KEY)
-        run: earthly --platform=linux/arm64 +test-all
+        run: earthly --platform=linux/arm64 --ci --remote-cache=ghcr.io/${{ github.repository }}:cache --push +test-all
       
       - name: Test (with SauceLabs)
         if: success() && matrix.SAUCE && matrix.SAUCE_ACCESS_KEY
-        run: earthly --platform=linux/arm64 +test --TEST=js
+        run: earthly --platform=linux/arm64 --ci --remote-cache=ghcr.io/${{ github.repository }}:cache --push +test --TEST=js
         env:
           SAUCE_ACCESS_KEY: matrix.SAUCE_ACCESS_KEY
       

+ 15 - 2
Earthfile

@@ -32,6 +32,8 @@ neko:
         PATH=$NEKOPATH:$PATH                                                                                    && \
         neko -version
     
+    SAVE IMAGE --cache-hint
+    
 build-environment:
     FROM +neko
     
@@ -45,6 +47,8 @@ build-environment:
         apt-get autoremove -y && \
         apt-get clean -y
         
+    SAVE IMAGE --cache-hint
+        
 build:
     FROM +build-environment
     
@@ -77,6 +81,7 @@ build:
     
     SAVE ARTIFACT ./out/* AS LOCAL out/$TARGETPLATFORM/
     SAVE ARTIFACT ./haxe* AS LOCAL out/$TARGETPLATFORM/
+    SAVE IMAGE --cache-hint
     
 build-multiarch:
     ARG ADD_REVISION
@@ -121,18 +126,20 @@ test-environment:
     ENV LANGUAGE=en_US:en  
     ENV LC_ALL=en_US.UTF-8
     
+    SAVE IMAGE --cache-hint
+    
 INSTALL_PACKAGES:
     COMMAND
     ARG PACKAGES
     RUN set -ex && \
         apt-get update -qqy && \
         apt-get install -qqy $PACKAGES && \
-        apt-get autoremove -y && \
-        apt-get clean -y
+        apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* 
     
 test-environment-java:
     FROM +test-environment
     DO +INSTALL_PACKAGES --PACKAGES="default-jdk"
+    SAVE IMAGE --cache-hint
     
 test-environment-js:
     # somehow js tests require hxjava which in turns require javac
@@ -141,24 +148,29 @@ test-environment-js:
 test-environment-python:
     FROM +test-environment
     DO +INSTALL_PACKAGES --PACKAGES="python3"
+    SAVE IMAGE --cache-hint
     
 test-environment-php:
     FROM +test-environment
     DO +INSTALL_PACKAGES --PACKAGES="php-cli php-mbstring php-sqlite3"
+    SAVE IMAGE --cache-hint
     
 test-environment-cs:
     FROM +test-environment
     DO +INSTALL_PACKAGES --PACKAGES="mono-devel mono-mcs"
+    SAVE IMAGE --cache-hint
     
 test-environment-hl:
     FROM +test-environment
     DO +INSTALL_PACKAGES --PACKAGES="cmake ninja-build libturbojpeg-dev libpng-dev zlib1g-dev libvorbis-dev"
+    SAVE IMAGE --cache-hint
     
 test-environment-lua:
     # hererocks uses pip
     FROM +test-environment-python 
     DO +INSTALL_PACKAGES --PACKAGES="libssl-dev libreadline-dev python3-pip unzip libpcre3-dev cmake"
     RUN ln -s /root/.local/bin/hererocks /bin/
+    SAVE IMAGE --cache-hint
     
 test-environment-cpp:
     FROM +test-environment
@@ -174,6 +186,7 @@ test-environment-cpp:
     END
     
     DO +INSTALL_PACKAGES --PACKAGES=$PACKAGES
+    SAVE IMAGE --cache-hint
     
 test:
     ARG TEST # macro, js, hl, cpp, java ,jvm, cs, php, python, lua, neko