Skip to content

Commit

Permalink
Migrate to Github action [1.1.x] (#2203)
Browse files Browse the repository at this point in the history
  • Loading branch information
liranbg committed May 19, 2021
1 parent 9e6b440 commit d7c9d6e
Show file tree
Hide file tree
Showing 6 changed files with 299 additions and 72 deletions.
143 changes: 143 additions & 0 deletions .github/workflows/ci.yaml
@@ -0,0 +1,143 @@
name: CI

on:
pull_request:
branches:
- 1.1.x
push:
branches:
- 1.1.x

env:
GO_VERSION: 1.12.x
GO111MODULE: off
GOPATH: /home/runner/work/nuclio/nuclio/go
NUCLIO_LABEL: ${{ github.run_number }}

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Dump github context
run: echo "$GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJson(github) }}

- name: Dump runner context
run: echo "$RUNNER_CONTEXT"
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}

- uses: actions/checkout@v2
with:
fetch-depth: 1
path: go/src/github.com/nuclio/nuclio

- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Lint
run: |
go get github.com/v3io/v3io-go-http
go get github.com/nuclio/logger
go get github.com/nuclio/nuclio-sdk-go \
&& cd $GOPATH/src/github.com/nuclio/nuclio-sdk-go \
&& git checkout v0.0.1 \
&& cd $GOPATH/src/github.com/nuclio/nuclio
go get github.com/nuclio/amqp
go get github.com/v3io/scaler-types \
&& cd $GOPATH/src/github.com/v3io/scaler-types \
&& git checkout v1.0.0 \
&& cd $GOPATH/src/github.com/nuclio/nuclio
make lint
test_short:
name: Test short
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
path: go/src/github.com/nuclio/nuclio

- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Run short test
run: |
go get github.com/v3io/v3io-go-http
go get github.com/nuclio/logger
go get github.com/nuclio/nuclio-sdk-go \
&& cd $GOPATH/src/github.com/nuclio/nuclio-sdk-go \
&& git checkout v0.0.1 \
&& cd $GOPATH/src/github.com/nuclio/nuclio
go get github.com/nuclio/amqp
go get -d golang.org/x/net/...
go get github.com/v3io/scaler-types \
&& cd $GOPATH/src/github.com/v3io/scaler-types \
&& git checkout v1.0.0 \
&& cd $GOPATH/src/github.com/nuclio/nuclio
make test-short
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Dump github context
run: echo "$GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJson(github) }}

- name: Dump runner context
run: echo "$RUNNER_CONTEXT"
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}

- name: Dump github ref
run: echo "$GITHUB_REF"

- uses: actions/checkout@v2
with:
fetch-depth: 1
path: go/src/github.com/nuclio/nuclio

# since github-actions gives us 14G only, and fills it up with some garbage
# we will free up some space for us (~2GB)
- name: Freeing up disk space
run: |
chmod +x "${GITHUB_WORKSPACE}/go/src/github.com/nuclio/nuclio/hack/scripts/ci/free-space.sh"
"${GITHUB_WORKSPACE}/go/src/github.com/nuclio/nuclio/hack/scripts/ci/free-space.sh"
- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Build
run: |
go get github.com/v3io/v3io-go-http
go get github.com/nuclio/logger
go get github.com/nuclio/nuclio-sdk-go \
&& cd $GOPATH/src/github.com/nuclio/nuclio-sdk-go \
&& git checkout v0.0.1 \
&& cd $GOPATH/src/github.com/nuclio/nuclio
go get github.com/nuclio/amqp
go get -d golang.org/x/net/...
go get github.com/v3io/scaler-types \
&& cd $GOPATH/src/github.com/v3io/scaler-types \
&& git checkout v1.0.0 \
&& cd $GOPATH/src/github.com/nuclio/nuclio
make docker-images
env:
NUCLIO_DOCKER_REPO: ${{ env.REPO }}/${{ env.REPO_NAME }}

- name: Build binaries
run: |
cd $GOPATH/src/github.com/nuclio/nuclio
NUCLIO_OS=linux NUCLIO_ARCH=amd64 make tools
NUCLIO_OS=darwin NUCLIO_ARCH=amd64 make tools
NUCLIO_OS=windows NUCLIO_ARCH=amd64 make tools
env:
NUCLIO_NUCTL_CREATE_SYMLINK: false
97 changes: 97 additions & 0 deletions .github/workflows/release.yaml
@@ -0,0 +1,97 @@
name: Release

on:
release:
types:
- created

env:
REPO: quay.io
REPO_NAME: nuclio
GO_VERSION: 1.12.x
GO111MODULE: off
GOPATH: /home/runner/work/nuclio/nuclio/go

jobs:
release:
name: Release
runs-on: ubuntu-latest

if: github.repository == 'nuclio/nuclio'
steps:
- name: Dump github context
run: echo "$GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJson(github) }}

- name: Dump runner context
run: echo "$RUNNER_CONTEXT"
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}

- name: Dump github ref
run: echo "$GITHUB_REF"

- name: Set NUCLIO_LABEL to release tag
run: |
echo "NUCLIO_LABEL=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- uses: actions/checkout@v2
with:
fetch-depth: 1
path: go/src/github.com/nuclio/nuclio

- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

# since github-actions gives us 14G only, and fills it up with some garbage
# we will free up some space for us (~2GB)
- name: Freeing up disk space
run: |
chmod +x "${GITHUB_WORKSPACE}/go/src/github.com/nuclio/nuclio/hack/scripts/ci/free-space.sh"
"${GITHUB_WORKSPACE}/go/src/github.com/nuclio/nuclio/hack/scripts/ci/free-space.sh"
- uses: azure/docker-login@v1
with:
login-server: ${{ env.REPO }}
username: ${{ secrets.QUAYIO_DOCKER_USERNAME }}
password: ${{ secrets.QUAYIO_DOCKER_PASSWORD }}

- name: Build
run: |
go get github.com/v3io/v3io-go-http
go get github.com/nuclio/logger
go get github.com/nuclio/nuclio-sdk-go \
&& cd $GOPATH/src/github.com/nuclio/nuclio-sdk-go \
&& git checkout v0.0.1 \
&& cd $GOPATH/src/github.com/nuclio/nuclio
go get github.com/nuclio/amqp
go get github.com/v3io/scaler-types \
&& cd $GOPATH/src/github.com/v3io/scaler-types \
&& git checkout v1.0.0 \
&& cd $GOPATH/src/github.com/nuclio/nuclio
make docker-images
env:
NUCLIO_DOCKER_REPO: ${{ env.REPO }}/${{ env.REPO_NAME }}

- name: Push images
run: |
make push-docker-images
env:
NUCLIO_DOCKER_REPO: ${{ env.REPO }}/${{ env.REPO_NAME }}

- name: Build binaries
run: |
cd $GOPATH/src/github.com/nuclio/nuclio
NUCLIO_OS=linux NUCLIO_ARCH=amd64 make tools
NUCLIO_OS=darwin NUCLIO_ARCH=amd64 make tools
NUCLIO_OS=windows NUCLIO_ARCH=amd64 make tools
env:
NUCLIO_NUCTL_CREATE_SYMLINK: false

- name: Upload binaries
uses: AButler/upload-release-assets@v2.0
with:
files: '/home/runner/work/nuclio/nuclio/go/bin/nuctl-*'
repo-token: ${{ secrets.GITHUB_TOKEN }}
72 changes: 0 additions & 72 deletions .travis.yml

This file was deleted.

8 changes: 8 additions & 0 deletions Makefile
Expand Up @@ -145,13 +145,16 @@ print-docker-images:
# Tools
#

NUCLIO_NUCTL_CREATE_SYMLINK := $(if $(NUCLIO_NUCTL_CREATE_SYMLINK),$(NUCLIO_NUCTL_CREATE_SYMLINK),true)
NUCTL_BIN_NAME = nuctl-$(NUCLIO_LABEL)-$(NUCLIO_OS)-$(NUCLIO_ARCH)
NUCTL_TARGET = $(GOPATH)/bin/nuctl

nuctl: ensure-gopath
$(GO_BUILD_TOOL) -o /go/bin/$(NUCTL_BIN_NAME) cmd/nuctl/main.go
@rm -f $(NUCTL_TARGET)
ifeq ($(NUCLIO_NUCTL_CREATE_SYMLINK), true)
@ln -sF $(GOPATH)/bin/$(NUCTL_BIN_NAME) $(NUCTL_TARGET)
endif

processor: ensure-gopath
docker build --file cmd/processor/Dockerfile --tag $(NUCLIO_DOCKER_REPO)/processor:$(NUCLIO_DOCKER_IMAGE_TAG) .
Expand Down Expand Up @@ -313,6 +316,11 @@ IMAGES_TO_PUSH += $(NUCLIO_DOCKER_HANDLER_BUILDER_JAVA_ONBUILD_IMAGE_NAME)
#
# Testing
#

.PHONY: fmt
fmt:
gofmt -s -w .

.PHONY: lint
lint: ensure-gopath
@echo Installing linters...
Expand Down
24 changes: 24 additions & 0 deletions hack/scripts/ci/add-remove-labels.js
@@ -0,0 +1,24 @@
module.exports = async ({github, context, prNumber, labelsToAdd, labelsToRemove}) => {

console.log(`Adding labels ${labelsToAdd} to PR #${prNumber}`)
await github.issues.addLabels({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labelsToAdd
})

console.log(`Removing labels ${labelsToRemove} from PR #${prNumber}`)
await Promise.all(labelsToRemove.map(labelName => github.issues.removeLabel({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
name: labelName
}).catch(error => {
if (error.toString().toLowerCase().includes('label does not exist')) {
console.log(`Ignoring not existing label error: ${error.toString()}`)
return
}
throw error
})))
}
27 changes: 27 additions & 0 deletions hack/scripts/ci/free-space.sh
@@ -0,0 +1,27 @@
#!/usr/bin/env sh

print_free_space() {
df --human-readable
}

# before cleanup
print_free_space

# clean unneeded os packages and misc
sudo apt-get remove --yes '^dotnet-.*' 'php.*' azure-cli google-cloud-sdk google-chrome-stable firefox powershell
sudo apt-get autoremove --yes
sudo apt clean

# cleanup unneeded share dirs ~30GB
sudo rm --recursive --force \
/usr/local/lib/android \
/usr/share/dotnet \
/usr/share/miniconda \
/usr/share/dotnet \
/usr/share/swift

# clean unneeded docker images
docker system prune --all --force

# post cleanup
print_free_space

0 comments on commit d7c9d6e

Please sign in to comment.