fix: make api-test download dag-to-lua if needed (#1374)
diff --git a/.github/workflows/backend-unit-test.yml b/.github/workflows/backend-unit-test.yml
index 40d7dbf..d6303e0 100644
--- a/.github/workflows/backend-unit-test.yml
+++ b/.github/workflows/backend-unit-test.yml
@@ -24,13 +24,6 @@
steps:
- uses: actions/checkout@v2
- - name: get lua lib
- run: |
- wget https://github.com/api7/dag-to-lua/archive/v1.1.tar.gz
- sudo mkdir -p ./api/dag-to-lua
- tar -zxvf v1.1.tar.gz
- sudo mv ./dag-to-lua-1.1/lib/* ./api/dag-to-lua/
-
- name: setup go
uses: actions/setup-go@v2.1.3
with:
diff --git a/Makefile b/Makefile
index 0937206..66b41b8 100644
--- a/Makefile
+++ b/Makefile
@@ -55,10 +55,21 @@
endif
+### dag-lib: get dag-lib
+.PHONY: dag-lib
+dag-lib:
+ifeq ("$(wildcard api/dag-to-lua/dag-to-lua.lua)", "")
+ wget https://github.com/api7/dag-to-lua/archive/v1.1.tar.gz -P /tmp
+ tar -zxvf /tmp/v1.1.tar.gz -C /tmp
+ mkdir ./api/dag-to-lua
+ cp -r /tmp/dag-to-lua-1.1/lib/* ./api/dag-to-lua
+endif
+
+
### api-test: Run the tests of manager-api
.PHONY: api-test
-api-test: api-default
- cd api/ && APISIX_API_WORKDIR=$$PWD ENV=test go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
+api-test: api-default dag-lib
+ cd api/ && APISIX_API_WORKDIR=$$PWD ENV=test go test -v -count=1 -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
### api-run: Run the manager-api