Skip to content

Commit

Permalink
fix: API CICD error (apache#575)
Browse files Browse the repository at this point in the history
* fix: API CICD -- testing

* test

* test

* test

* fix mv force

* fix use `-u` to move

* fix remove first

* test

* test

* fix: only build when merging into master

* fix doc style
  • Loading branch information
nic-chen authored Oct 21, 2020
1 parent b074f24 commit eebaec0
Showing 3 changed files with 23 additions and 15 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/api_ci.yml
Original file line number Diff line number Diff line change
@@ -11,9 +11,8 @@ on:
jobs:

run-test:

runs-on: ubuntu-latest

services:
etcd:
image: bitnami/etcd:3.4.13
@@ -24,18 +23,19 @@ jobs:
ALLOW_NONE_AUTHENTICATION: yes

steps:

- uses: actions/checkout@v2

- name: run Makefile
run: |
make license-check
- name: get lua lib
run: |
wget https://github.com/api7/dag-to-lua/archive/v1.1.tar.gz
sudo mkdir -p /go/manager-api/dag-to-lua/
tar -zxvf v1.1.tar.gz
sudo mv ./dag-to-lua-1.1/lib/* /go/manager-api/dag-to-lua/
- name: install runtime
run: |
sudo apt-get update
@@ -44,17 +44,19 @@ jobs:
sudo apt update
export GO111MOUDULE=on
sudo apt install golang-1.14-go
- name: generate json schema
working-directory: ./api
run: |
wget https://github.com/apache/apisix/archive/master.zip
mkdir ./build-tools/apisix/
mkdir -p ./build-tools/apisix/
unzip master.zip
sudo mv ./apisix-master/apisix/* ./build-tools/apisix/
rm -rf ./apisix-master
cd ./build-tools/ && lua schema-sync.lua > ../conf/schema.json
- name: run test
working-directory: ./api
run: |
export APIX_ETCD_ENDPOINTS=127.0.0.1:2379
go test ./...
go test ./...
15 changes: 10 additions & 5 deletions .github/workflows/api_cicd.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ name: API CI && CD

on:
push:
branches:
branches:
- master

jobs:
@@ -21,15 +21,17 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: run Makefile
- name: license check
run: |
make license-check
- name: get lua lib
run: |
wget https://github.com/api7/dag-to-lua/archive/v1.1.tar.gz
sudo mkdir -p /go/manager-api/dag-to-lua/
tar -zxvf v1.1.tar.gz
sudo mv ./dag-to-lua-1.1/lib/* /go/manager-api/dag-to-lua/
- name: install runtime
run: |
sudo apt-get update
@@ -38,28 +40,31 @@ jobs:
sudo apt update
export GO111MOUDULE=on
sudo apt install golang-1.14-go
- name: generate json schema
working-directory: ./api
run: |
wget https://github.com/apache/apisix/archive/master.zip
mkdir ./build-tools/apisix/
mkdir -p ./build-tools/apisix/
unzip master.zip
sudo mv ./apisix-master/apisix/* ./build-tools/apisix/
rm -rf ./apisix-master
cd ./build-tools/ && lua schema-sync.lua > ../conf/schema.json
- name: run test
working-directory: ./api
run: |
export APIX_ETCD_ENDPOINTS=127.0.0.1:2379
go test ./...
- uses: Azure/docker-login@v1
with:
login-server: apisixacr.azurecr.cn
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: build and push docker image
- name: build and push docker image
working-directory: ./api
run: |
cd ./api
docker build . -t apisixacr.azurecr.cn/managerapi:${{ github.sha }}
docker push apisixacr.azurecr.cn/managerapi:${{ github.sha }}
11 changes: 6 additions & 5 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -19,8 +19,8 @@ FROM golang:1.13.8 AS build-env

WORKDIR /go/src/github.com/apisix/manager-api
COPY . .
RUN mkdir /go/manager-api \
&& mkdir /go/manager-api/build-tools \
RUN mkdir -p /go/manager-api \
&& mkdir -p /go/manager-api/build-tools \
&& go env -w GOPROXY=https://goproxy.io,direct \
&& export GOPROXY=https://goproxy.io \
&& go build -o /go/manager-api/manager-api \
@@ -34,13 +34,14 @@ RUN mkdir /go/manager-api \

RUN wget https://github.com/api7/dag-to-lua/archive/v1.1.tar.gz \
&& tar -zxvf v1.1.tar.gz \
&& mkdir /go/manager-api/dag-to-lua \
&& mv ./dag-to-lua-1.1/lib/* /go/manager-api/dag-to-lua/
&& mkdir -p /go/manager-api/dag-to-lua \
&& mv -u ./dag-to-lua-1.1/lib/* /go/manager-api/dag-to-lua/

RUN wget https://github.com/apache/apisix/archive/master.zip \
&& mkdir /go/manager-api/build-tools/apisix \
&& apt-get update && apt-get install zip -y \
&& unzip master.zip \
&& rm -rf /go/manager-api/build-tools/apisix/ \
&& mkdir -p /go/manager-api/build-tools/apisix \
&& mv ./apisix-master/apisix/* /go/manager-api/build-tools/apisix/

FROM alpine:3.11

0 comments on commit eebaec0

Please sign in to comment.