You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by ke...@apache.org on 2023/02/24 02:15:21 UTC

[skywalking-eyes] 01/01: gha: switch to composite running mode and set up cache

This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch gha/improve-speed
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 5fba79af09fa67205aa986612b4d77d43cb7f7c0
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Fri Feb 24 10:15:11 2023 +0800

    gha: switch to composite running mode and set up cache
---
 Makefile   | 10 ++++++++++
 action.yml | 47 ++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index ad551fe..eecfd7e 100644
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,7 @@
 HUB ?= docker.io/apache
 PROJECT ?= license-eye
 VERSION ?= latest
+INSTALL_DIR ?= /usr/local/bin
 OUT_DIR = bin
 ARCH := $(shell uname)
 OSNAME := $(if $(findstring Darwin,$(ARCH)),darwin,linux)
@@ -28,6 +29,7 @@ GO_BUILD = $(GO) build
 GO_TEST = $(GO) test
 GO_LINT = $(GO_PATH)/bin/golangci-lint
 GO_BUILD_LDFLAGS = -X github.com/apache/skywalking-eyes/commands.version=$(VERSION)
+GOOS ?= $(shell $(GO) env GOOS)
 
 PLANTUML_VERSION = 1.2021.9
 
@@ -142,3 +144,11 @@ verify-docs: docs-gen
 		git diff --color --word-diff --exit-code docs; \
 		exit 1; \
 	fi
+
+.PHONY: install
+install: $(GOOS)
+	-cp $(OUT_DIR)/$(GOOS)/$(PROJECT) $(INSTALL_DIR)
+
+.PHONY: uninstall
+uninstall: $(GOOS)
+	-rm $(INSTALL_DIR)/$(PROJECT)
diff --git a/action.yml b/action.yml
index b4e8ce9..faa0874 100644
--- a/action.yml
+++ b/action.yml
@@ -42,14 +42,39 @@ inputs:
     required: false
     default: check
 runs:
-  using: docker
-  image: Dockerfile
-  env:
-    GITHUB_TOKEN: ${{ inputs.token }}
-  args:
-    - -v
-    - ${{ inputs.log }}
-    - -c
-    - ${{ inputs.config }}
-    - header
-    - ${{ inputs.mode }}
+  using: "composite"
+  steps:
+    - name: Set up Go 1.18
+      uses: actions/setup-go@v2
+      with:
+        go-version: 1.18
+    - if: runner.os == 'Linux'
+      uses: actions/cache@v3
+      with:
+        path: |
+          ~/.cache/go-build
+          ~/go/pkg/mod
+        key: license-eye-${{ runner.os }}-go-${{ hashFiles(format('{0}/{1}', github.action_path, 'go.sum')) }}
+        restore-keys: license-eye-${{ runner.os }}-go-
+    - if: runner.os == 'macOS'
+      uses: actions/cache@v3
+      with:
+        path: |
+          ~/Library/Caches/go-build
+          ~/go/pkg/mod
+        key: license-eye-${{ runner.os }}-go-${{ hashFiles(format('{0}/{1}', github.action_path, 'go.sum')) }}
+        restore-keys: license-eye-${{ runner.os }}-go-
+    - if: runner.os == 'Windows'
+      uses: actions/cache@v3
+      with:
+        path: |
+          ~\AppData\Local\go-build
+          ~\go\pkg\mod
+        key: license-eye-${{ runner.os }}-go-${{ hashFiles(format('{0}/{1}', github.action_path, 'go.sum')) }}
+        restore-keys: license-eye-${{ runner.os }}-go-
+    - shell: bash
+      run: make -C $GITHUB_ACTION_PATH install
+    - shell: bash
+      env:
+        GITHUB_TOKEN: ${{ inputs.token }}
+      run: license-eye -v ${{ inputs.log }} -c ${{ inputs.config }} header ${{ inputs.mode }}