Compare commits
3 Commits
v0.7.1
...
0.7.2-alph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
536b757602 | ||
|
|
ddff53fff2 | ||
|
|
ae87215cfb |
29
.github/workflows/ci.yml
vendored
29
.github/workflows/ci.yml
vendored
@@ -7,7 +7,7 @@ jobs:
|
||||
- name: setup Go 1.12
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
version: 1.12
|
||||
go-version: 1.12
|
||||
id: go
|
||||
|
||||
- name: check out
|
||||
@@ -64,7 +64,7 @@ jobs:
|
||||
DEBUG=true ./build/fx deploy -n hello -p 12345 examples/functions/JavaScript/func.js
|
||||
./build/fx destroy hello
|
||||
rm ${KUBECONFIG}
|
||||
Release:
|
||||
Installation:
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: [Test]
|
||||
strategy:
|
||||
@@ -72,23 +72,20 @@ jobs:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macOS-latest
|
||||
- windows-latest
|
||||
# TODO enable window and mac
|
||||
# - macOS-latest
|
||||
# - windows-latest
|
||||
version:
|
||||
- latest
|
||||
- v0.117.0
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
version: '1.12'
|
||||
- name: GoReleaser
|
||||
if: github.ref == 'production'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
uses: goreleaser/goreleaser-action@master
|
||||
with:
|
||||
version: ${{ matrix.version }}
|
||||
args: release --rm-dist
|
||||
- name: install fx
|
||||
run: |
|
||||
# install with non-root user
|
||||
bash ./scripts/install.sh
|
||||
./fx -v
|
||||
# install with root
|
||||
sudo bash ./scripts/install.sh
|
||||
./fx -v
|
||||
|
||||
117
.github/workflows/release.yml
vendored
Normal file
117
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*--auto-release'
|
||||
- master
|
||||
- production
|
||||
name: release
|
||||
jobs:
|
||||
Test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: setup Go 1.12
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.12
|
||||
id: go
|
||||
|
||||
- name: check out
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: setup docker
|
||||
run: |
|
||||
./scripts/provision.sh
|
||||
|
||||
- name: setup k8s and kind
|
||||
run: |
|
||||
export GOBIN=$(go env GOPATH)/bin
|
||||
export PATH=$PATH:$GOBIN
|
||||
mkdir -p $GOBIN
|
||||
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
|
||||
chmod +x kubectl && mv kubectl $GOBIN
|
||||
wget https://github.com/kubernetes-sigs/kind/releases/download/v0.5.0/kind-linux-amd64 && chmod +x kind-linux-amd64 && mv kind-linux-amd64 $GOBIN/kind
|
||||
./scripts/setup_kind.sh
|
||||
|
||||
- name: unit test
|
||||
env:
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
run: |
|
||||
export KUBECONFIG=/home/runner/.kube/kind-config-fx-test
|
||||
DEBUG=true go test -v ./container_runtimes/... ./deploy/...
|
||||
|
||||
- name: build fx
|
||||
run: |
|
||||
make build
|
||||
|
||||
- name: lint
|
||||
run: |
|
||||
export GOBIN=$(go env GOPATH)/bin
|
||||
export PATH=$PATH:$GOBIN
|
||||
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
golangci-lint run
|
||||
|
||||
|
||||
- name: test fx cli
|
||||
run: |
|
||||
echo $KUBECONFIG
|
||||
unset KUBECONFIG
|
||||
make cli-test
|
||||
|
||||
- name: test AKS
|
||||
env:
|
||||
AKS_KUBECONFIG: ${{ secrets.AKS_KUBECONFIG }}
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
run: |
|
||||
export KUBECONFIG=${HOME}/.kube/aks
|
||||
echo ${AKS_KUBECONFIG} | base64 -d > $KUBECONFIG
|
||||
DEBUG=true ./build/fx deploy -n hello -p 12345 examples/functions/JavaScript/func.js
|
||||
./build/fx destroy hello
|
||||
rm ${KUBECONFIG}
|
||||
Release:
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: [Test]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
# - macOS-latest
|
||||
# - windows-latest
|
||||
version:
|
||||
- latest
|
||||
# - v0.117.0
|
||||
steps:
|
||||
- name: setup Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '1.12'
|
||||
- name: checkout
|
||||
uses: actions/checkout@v1
|
||||
- name: release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
|
||||
run: |
|
||||
git config --global user.email "h.minghe@gmail.com"
|
||||
git config --global user.name "Minghe Huang"
|
||||
|
||||
commit=$(git rev-parse --short HEAD)
|
||||
version=$(cat fx.go| grep Version | awk -F'"' '{print $2}')
|
||||
|
||||
echo "workflow is running on branch ${GITHUB_REF}"
|
||||
|
||||
if [[ ${GITHUB_REF} == "refs/heads/production" ]];then
|
||||
version=${version}-alpha.${commit}
|
||||
echo "alpha release $version"
|
||||
elif [[ "${GITHUB_REF}" == *--auto-release ]];then
|
||||
version=${version}-alpha.${commit}
|
||||
echo "alpha release $version"
|
||||
elif [[ ${GITHUB_REF} == "refs/heads/production" ]];then
|
||||
echo "official release $version"
|
||||
else
|
||||
echo "skip release on $GITHUB_REF"
|
||||
exit 0
|
||||
fi
|
||||
git tag -a ${version} -m "auto release"
|
||||
curl -sL https://git.io/goreleaser | bash -s -- --skip-validate
|
||||
@@ -2,6 +2,7 @@ fx
|
||||
------
|
||||
Poor man's function as a service.
|
||||
<br/>
|
||||

|
||||

|
||||
[](https://codecov.io/gh/metrue/fx)
|
||||
[](https://goreportcard.com/report/github.com/metrue/fx)
|
||||
@@ -50,13 +51,11 @@ brew install metrue/fx/fx
|
||||
via cURL
|
||||
|
||||
```shell
|
||||
# Install to local directory
|
||||
curl -o- https://raw.githubusercontent.com/metrue/fx/master/scripts/install.sh | bash
|
||||
```
|
||||
|
||||
or Wget
|
||||
|
||||
```shell
|
||||
wget -qO- https://raw.githubusercontent.com/metrue/fx/master/scripts/install.sh | bash
|
||||
# Install to /usr/local/bin/
|
||||
curl -o- https://raw.githubusercontent.com/metrue/fx/master/scripts/install.sh | sudo bash
|
||||
```
|
||||
|
||||
fx will be installed into /usr/local/bin, sometimes you may need `source ~/.zshrc` or `source ~/.bashrc` to make fx available in `$PAHT`.
|
||||
|
||||
2
fx.go
2
fx.go
@@ -27,7 +27,7 @@ func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "fx"
|
||||
app.Usage = "makes function as a service"
|
||||
app.Version = "0.7.1"
|
||||
app.Version = "0.7.2"
|
||||
|
||||
app.Commands = []cli.Command{
|
||||
{
|
||||
|
||||
@@ -1,41 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
fx_has() {
|
||||
set -e
|
||||
|
||||
has() {
|
||||
type "$1" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
get_package_url() {
|
||||
label=""
|
||||
platform=""
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
label="macOS"
|
||||
platform="macOS"
|
||||
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
|
||||
label="Tux"
|
||||
platform="Tux"
|
||||
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
|
||||
label="windows"
|
||||
platform="windows"
|
||||
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
|
||||
label="windows"
|
||||
platform="windows"
|
||||
fi
|
||||
|
||||
curl -s https://api.github.com/repos/metrue/fx/releases/latest | grep browser_download_url | awk -F'"' '{print $4}' | grep ${label}
|
||||
curl https://api.github.com/repos/metrue/fx/releases/latest | grep browser_download_url | awk -F'"' '{print $4}' | grep ${platform}
|
||||
}
|
||||
|
||||
download_and_install() {
|
||||
local url=$1
|
||||
# TODO we can do it on one line
|
||||
rm -rf fx.tar.gz
|
||||
curl -o fx.tar.gz -L -O ${url} && tar -xvzf ./fx.tar.gz --exclude=*.md -C /usr/local/bin
|
||||
rm -rf ./fx.tar.gz
|
||||
url=$(get_package_url)
|
||||
tarFile="fx.tar.gz"
|
||||
targetFile=$(pwd)
|
||||
|
||||
userid=$(id -u)
|
||||
if [ "$userid" != "0" ]; then
|
||||
tarFile="$(pwd)/${tarFile}"
|
||||
else
|
||||
tarFile="/tmp/${tarFile}"
|
||||
targetFile="/usr/local/bin"
|
||||
fi
|
||||
|
||||
if [ -e $tarFile ]; then
|
||||
rm -rf $tarFile
|
||||
fi
|
||||
|
||||
echo "Downloading fx from $url"
|
||||
curl -sSLf $url --output $tarFile
|
||||
if [ "$?" == "0" ]; then
|
||||
echo "Download complete, saved to $tarFile"
|
||||
fi
|
||||
|
||||
echo "Installing fx to ${targetFile}"
|
||||
tar -xvzf ${tarFile} --exclude=*.md -C ${targetFile}
|
||||
echo "fx installed successfully at ${targetFile}"
|
||||
${targetFile}/fx -v
|
||||
|
||||
echo "Cleaning up ${tarFile}"
|
||||
rm -rf ${tarFile}
|
||||
}
|
||||
|
||||
main() {
|
||||
if fx_has "docker"; then
|
||||
url=$(get_package_url)
|
||||
if [ ${url}"X" != "X" ];then
|
||||
download_and_install ${url}
|
||||
fi
|
||||
if has "curl";then
|
||||
download_and_install
|
||||
else
|
||||
echo "No Docker found on this host"
|
||||
echo " - Docker installation: https://docs.docker.com/engine/installation"
|
||||
echo "You need cURL to use this script"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user