Skip to content

Commit

Permalink
.github/workflows+test_args.sh: Separate Linux and Docker builds
Browse files Browse the repository at this point in the history
Update test_args.sh to be runnable in GH action ubuntu env
  • Loading branch information
yondonfu committed May 11, 2021
1 parent f8eef75 commit 6b85744
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 66 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Docker Build
on:
pull_request:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-16.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Needed for commands that depend on git tags
fetch-depth: 0
- name: Set global environment variables
run: |
echo "PKG_CONFIG_PATH=/root/compiled/lib/pkgconfig" >> $GITHUB_ENV
echo "GOPATH=/go" >> $GITHUB_ENV
- name: DockerHub login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASS }}
- name: Build Linux specific builder container
run: |
docker pull livepeerci/build-platform:latest || echo 'no pre-existing cache found'
docker build -t livepeerci/build-platform:latest --cache-from=livepeerci/build-platform:latest -f docker/Dockerfile.build-linux .
docker push livepeerci/build-platform:latest
- name: Build livepeer in a container shared between Linux and Windows
run: |
docker pull livepeerci/build:latest || echo 'no pre-existing cache found'
./ci_env.sh docker build --build-arg HIGHEST_CHAIN_TAG -t livepeerci/build:latest --cache-from=livepeerci/build:latest -f docker/Dockerfile.build .
docker push livepeerci/build:latest
- name: Build minimal livepeer distributable
run: |
# We publish two tags for each build:
# livepeer/go-livepeer:BRANCH_NAME and livepeer/go-livepeer:VERSION_STRING. Both are useful
# to pull from in different contexts.
# Our Docker tag name should be our branch name with just alphanums
BRANCH_TAG=$(echo $GITHUB_REF | sed 's/refs\/heads\///' | sed 's/\//-/g' | tr -cd '[:alnum:]_-')
VERSION_TAG=$(./print_version.sh)
docker build -t current-build -f docker/Dockerfile.release-linux .
for TAG in $BRANCH_TAG $VERSION_TAG; do
docker tag current-build livepeer/go-livepeer:${TAG}-linux
docker push livepeer/go-livepeer:${TAG}-linux
# Manifest step is optional in case the Windows build hasn't finished yet
docker manifest create livepeer/go-livepeer:${TAG} livepeer/go-livepeer:${TAG}-linux livepeer/go-livepeer:${TAG}-windows || true
docker manifest push livepeer/go-livepeer:${TAG} || true
done
env:
GITHUB_REF: ${{ github.ref }}
168 changes: 104 additions & 64 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,79 +6,119 @@ on:
- master
jobs:
build:
runs-on: ubuntu-16.04
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v2
with:
# Needed for commands that depend on git tags
fetch-depth: 0
- name: Set global environment variables
run: |
echo "PKG_CONFIG_PATH=/root/compiled/lib/pkgconfig" >> $GITHUB_ENV
echo "GOPATH=/go" >> $GITHUB_ENV
- name: DockerHub login
uses: docker/login-action@v1
- name: Setup Go
uses: actions/setup-go@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASS }}
- name: Build Linux specific builder container
run: |
docker pull livepeerci/build-platform:latest || echo 'no pre-existing cache found'
docker build -t livepeerci/build-platform:latest --cache-from=livepeerci/build-platform:latest -f docker/Dockerfile.build-linux .
docker push livepeerci/build-platform:latest
- name: Build livepeer in a container shared between Linux and Windows
go-version: '1.15.5'
- name: Cache go modules
id: cache-go-mod
uses: actions/cache@v2.1.5
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Cache ffmpeg
id: cache-ffmpeg
uses: actions/cache@v2.1.5
with:
path: ~/compiled
key: ${{ runner.os }}-ffmpeg-${{ hashFiles('**/install_ffmpeg.sh') }}
restore-keys: |
${{ runner.os }}-ffmpeg
- name: Cache binaries
uses: actions/cache@v2.1.5
with:
path: ~/build
key: ${{ runner.os }}-binaries-${{ github.sha }}
- name: Install dependencies
run: |
docker pull livepeerci/build:latest || echo 'no pre-existing cache found'
./ci_env.sh docker build --build-arg HIGHEST_CHAIN_TAG -t livepeerci/build:latest --cache-from=livepeerci/build:latest -f docker/Dockerfile.build .
docker push livepeerci/build:latest
- name: Build minimal livepeer distributable
sudo apt-get update \
&& sudo apt-get install -y software-properties-common curl apt-transport-https \
&& sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 15CF4D18AF4F7421 \
&& sudo add-apt-repository "deb [arch=amd64] http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" \
&& sudo apt-get update \
&& sudo apt-get -y install clang-8 clang-tools-8 build-essential pkg-config autoconf gnutls-dev git python
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 30 \
&& sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 30
- name: Install go modules
if: steps.cache-go-mod.outputs.cache-hit != 'true'
run: go mod download
- name: Install ffmpeg
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: ./install_ffmpeg.sh
- name: Build binaries
run: |
# We publish two tags for each build:
# livepeer/go-livepeer:BRANCH_NAME and livepeer/go-livepeer:VERSION_STRING. Both are useful
# to pull from in different contexts.
# Our Docker tag name should be our branch name with just alphanums
BRANCH_TAG=$(echo $GITHUB_REF | sed 's/refs\/heads\///' | sed 's/\//-/g' | tr -cd '[:alnum:]_-')
VERSION_TAG=$(./print_version.sh)
docker build -t current-build -f docker/Dockerfile.release-linux .
for TAG in $BRANCH_TAG $VERSION_TAG; do
docker tag current-build livepeer/go-livepeer:${TAG}-linux
docker push livepeer/go-livepeer:${TAG}-linux
# Manifest step is optional in case the Windows build hasn't finished yet
docker manifest create livepeer/go-livepeer:${TAG} livepeer/go-livepeer:${TAG}-linux livepeer/go-livepeer:${TAG}-windows || true
docker manifest push livepeer/go-livepeer:${TAG} || true
done
export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig
./ci_env.sh make livepeer livepeer_cli livepeer_bench livepeer_router
rm -rf ~/build && mkdir ~/build && mv livepeer* ~/build/
env:
GITHUB_REF: ${{ github.ref }}

GITHUB_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }}
test:
runs-on: ubuntu-16.04
runs-on: ubuntu-18.04
needs: build
container:
image: livepeerci/build:latest
credentials:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASS }}
defaults:
run:
working-directory: /build
steps:
- name: Set global environment variables
run: |
echo "PKG_CONFIG_PATH=/root/compiled/lib/pkgconfig" >> $GITHUB_ENV
echo "GOPATH=/go" >> $GITHUB_ENV
- name: Lint
run: golangci-lint --disable-all --enable=gofmt --enable=vet --enable=golint --deadline=4m run pm verification
- name: Run unit tests
run: /bin/bash test.sh
- name: Local Docker build check
run: make localdocker
- name: Upload build
run: ./upload_build.sh
env:
GITHUB_REF: ${{ github.ref }}
GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }}
GCLOUD_SECRET: ${{ secrets.GCLOUD_SECRET }}
DISCORD_URL: ${{ secrets.DISCORD_URL }}
- name: Notify new build upload
run: curl -X POST https://holy-bread-207a.livepeer.workers.dev
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.15.5'
- name: Cache go modules
id: cache-go-mod
uses: actions/cache@v2.1.5
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Cache ffmpeg
id: cache-ffmpeg
uses: actions/cache@v2.1.5
with:
path: ~/compiled
key: ${{ runner.os }}-ffmpeg-${{ hashFiles('**/install_ffmpeg.sh') }}
restore-keys: |
${{ runner.os }}-ffmpeg
- name: Lint
run: |
export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.39.0
golangci-lint run --disable-all --enable=gofmt --enable=vet --enable=golint --deadline=4m pm verification
- name: Run tests
shell: bash
run: |
export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig
./test.sh
upload:
runs-on: ubuntu-18.04
needs: [build, test]
if: github.repository == 'livepeer/go-livepeer'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Needed for commands that depend on git tags
fetch-depth: 0
- name: Cache binaries
uses: actions/cache@v2.1.5
with:
path: ~/build
key: ${{ runner.os }}-binaries-${{ github.sha }}
- name: Upload build
run: cp ~/build/* . && ./upload_build.sh
env:
GITHUB_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }}
GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }}
GCLOUD_SECRET: ${{ secrets.GCLOUD_SECRET }}
DISCORD_URL: ${{ secrets.DISCORD_URL }}
- name: Notify new build upload
run: curl -X POST https://holy-bread-207a.livepeer.workers.dev
4 changes: 2 additions & 2 deletions test_args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
set -eux

# set a clean slate "home dir" for testing
TMPDIR=/tmp/livepeer-test-"$RANDOM"
TMPDIR=$PWD/tmp/livepeer-test-"$RANDOM"
DEFAULT_DATADIR="$TMPDIR"/.lpData
CUSTOM_DATADIR="$TMPDIR"/customDatadir
export HOME=$TMPDIR
rm -rf "$DEFAULT_DATADIR"
mkdir -p $TMPDIR # goclient should make the lpData datadir

Expand All @@ -22,6 +21,7 @@ ETH_KEY
ETH_ARGS="-ethKeystorePath $TMPDIR/key"
SLEEP=0.25

export HOME=$TMPDIR

run_lp () {
$TMPDIR/livepeer "$@" &
Expand Down

0 comments on commit 6b85744

Please sign in to comment.