Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate CircleCI workflows to GitHub Actions (2/3) #2298

Merged
merged 2 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 186 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
go run cmd/issuegenerator/main.go $TEST_RESULTS
setup-environment:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.splitloadtest.outputs.matrix }}
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand All @@ -58,8 +60,29 @@ jobs:
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
- name: Install tools
run: make install-tools
- name: split loadtest jobs
id: splitloadtest
run: |
TESTS="$(make -s testbed-list-loadtest | xargs echo|sed 's/ /|/g')"
TESTS=(${TESTS//|/ })
MATRIX="{\"include\":["
curr=""
for i in "${!TESTS[@]}"; do
if (( i > 0 && i % 2 == 0 )); then
curr+="|${TESTS[$i]}"
else
if [ -n "$curr" ] && (( i>1 )); then
MATRIX+=",{\"test\":\"$curr\"}"
elif [ -n "$curr" ]; then
MATRIX+="{\"test\":\"$curr\"}"
fi
curr="${TESTS[$i]}"
fi
done
MATRIX+="]}"
echo "::set-output name=matrix::$MATRIX"
- name: Upload tool binaries
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v1
bogdandrutu marked this conversation as resolved.
Show resolved Hide resolved
with:
name: tool-binaries
path: /home/runner/go/bin
Expand Down Expand Up @@ -128,7 +151,168 @@ jobs:
- name: Build collector for all archs
run: grep ^binaries-all-sys Makefile|fmt -w 1|tail -n +2|xargs make
- name: Upload collector binaries
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v1
with:
name: collector-binaries
path: ./bin
loadtest:
runs-on: ubuntu-latest
needs: [setup-environment]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup-environment.outputs.matrix) }}
env:
TEST_RESULTS: testbed/tests/results/junit/results.xml
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Download tool binaries
uses: actions/download-artifact@v2
with:
name: tool-binaries
path: /home/runner/go/bin
- name: Add execute permissions to tool binaries
run: chmod -R +x /home/runner/go/bin
- name: Setup env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Restore module cache
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
Comment on lines +166 to +190
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code seem to be duplicated a lot between jobs, is there a way to avoid this and have a common step that all jobs will run?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I dont think there is a way to reuse steps across jobs as we can't use YAML anchors. It seems like the GitHub team is aware this is a pain point though and working on an alternative feature soon :/

- name: Install fluentbit
if: ${{ contains(matrix.test, 'Log10kDPS') }}
run: |
wget https://packages.fluentbit.io/ubuntu/bionic/pool/main/t/td-agent-bit/td-agent-bit_1.5.3_amd64.deb
sudo dpkg -i ./td-agent-bit*.deb
echo "/opt/td-agent-bit/bin" >> $GITHUB_PATH
sudo ln -s /opt/td-agent-bit/bin/td-agent-bit /usr/local/bin/fluent-bit
- run: mkdir -p results && touch results/TESTRESULTS.md
- name: Loadtest
run: make testbed-loadtest
env:
TEST_ARGS: "-test.run=${{ matrix.test }}"
- name: Create test result archive # some test results have invalid characters
if: ${{ failure() || success() }}
continue-on-error: true
run: tar -cvf test_results.tar testbed/tests/results
- name: Upload test results
if: ${{ failure() || success() }}
continue-on-error: true
Comment on lines +203 to +209
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • making a tarball of the test results because some tests have filenames with invalid characters (namely the 0*0bytes test) which causes the upload action to fail.

  • if: ${{ failure() || success() }} this ensures that test results are uploaded even if the loadtest fails which can be useful for debugging

  • continue-on-error: true Sometimes (rarely, but still) the upload action fails due to a network error on github's side. This makes sure the entire job doesnt fail if the test results fail to upload

uses: actions/upload-artifact@v1
with:
name: test-results
path: test_results.tar
- name: GitHub issue generator
if: ${{ failure() && github.ref == 'ref/head/master' }}
run: |
go run cmd/issuegenerator/main.go $TEST_RESULTS
correctness:
runs-on: ubuntu-latest
needs: [setup-environment]
env:
TEST_RESULTS: testbed/tests/results/junit/results.xml
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Download tool binaries
uses: actions/download-artifact@v2
with:
name: tool-binaries
path: /home/runner/go/bin
- name: Setup env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Add execute permissions to tool binaries
run: chmod -R +x /home/runner/go/bin
- name: Restore module cache
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
- name: Loadtest
run: make testbed-correctness
- name: GitHub issue generator
if: ${{ failure() && github.ref == 'ref/head/master' }}
run: |
go run cmd/issuegenerator/main.go $TEST_RESULTS
build-package:
runs-on: ubuntu-latest
needs: [cross-compile]
strategy:
fail-fast: false
matrix:
package_type: ["deb", "rpm"]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Setup env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
mkdir bin/
- name: Install Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
- name: Install fpm and dependencies
run: gem install --no-document fpm -v 1.11.0
- name: Download tool binaries
uses: actions/download-artifact@v2
with:
name: tool-binaries
path: /home/runner/go/bin
- name: Download collector binaries
uses: actions/download-artifact@v2
with:
name: collector-binaries
path: ./bin
- name: Add execute permissions to downloaded binaries
run: |
chmod -R +x /home/runner/go/bin
chmod -R +x ./bin
- name: Set Release Tag
id: github_tag
run: |
TAG="${GITHUB_REF##*/}"
if [[ $TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+.* ]]
then
echo "::set-output name=tag::$TAG"
fi
- name: Build ${{ matrix.package_type }} amd64 package
run: ./internal/buildscripts/packaging/fpm/${{ matrix.package_type }}/build.sh "${{ steps.github_tag.outputs.tag }}" "amd64" "./dist/"
- name: Build ${{ matrix.package_type }} arm64 package
run: ./internal/buildscripts/packaging/fpm/${{ matrix.package_type }}/build.sh "${{ steps.github_tag.outputs.tag }}" "arm64" "./dist/"
- name: Test ${{ matrix.package_type }} package
run: |
if [[ "${{ matrix.package_type }}" = "deb" ]]; then
./internal/buildscripts/packaging/fpm/test.sh dist/otel-collector*amd64.deb
else
./internal/buildscripts/packaging/fpm/test.sh dist/otel-collector*x86_64.rpm
fi
- name: Upload Packages
uses: actions/upload-artifact@v1
with:
name: build-packages
path: ./dist
2 changes: 1 addition & 1 deletion testbed/testbed/receivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type DataReceiverBase struct {
Port int
}

const DefaultHost = "localhost"
const DefaultHost = "127.0.0.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line was causing an error with the fluentbit log test since localhost could not be resolved on the github actions runners.


func (mb *DataReceiverBase) ReportFatalError(err error) {
log.Printf("Fatal error reported: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions testbed/tests/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestIdleMode(t *testing.T) {
)
defer tc.Stop()

tc.SetResourceLimits(testbed.ResourceSpec{ExpectedMaxCPU: 4, ExpectedMaxRAM: 50})
tc.SetResourceLimits(testbed.ResourceSpec{ExpectedMaxCPU: 4, ExpectedMaxRAM: 55})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the GitHub Action runners the RAM utilization is consistently higher (probably due to some other background processes on the GitHub machine). Loadtests don't pass unless these values are adjusted a little 😞

tc.StartAgent()

tc.Sleep(tc.Duration)
Expand All @@ -53,7 +53,7 @@ func TestBallastMemory(t *testing.T) {
ballastSize uint32
maxRSS uint32
}{
{100, 50},
{100, 60},
{500, 70},
{1000, 100},
}
Expand Down
2 changes: 1 addition & 1 deletion testbed/tests/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestLog10kDPS(t *testing.T) {
receiver: testbed.NewOTLPDataReceiver(testbed.GetAvailablePort(t)),
resourceSpec: testbed.ResourceSpec{
ExpectedMaxCPU: 50,
ExpectedMaxRAM: 150,
ExpectedMaxRAM: 155,
},
extensions: flw.Extensions(),
},
Expand Down
4 changes: 2 additions & 2 deletions testbed/tests/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestMetric10kDPS(t *testing.T) {
testbed.NewOTLPDataReceiver(testbed.GetAvailablePort(t)),
testbed.ResourceSpec{
ExpectedMaxCPU: 50,
ExpectedMaxRAM: 60,
ExpectedMaxRAM: 65,
},
},
{
Expand All @@ -76,7 +76,7 @@ func TestMetric10kDPS(t *testing.T) {
testbed.NewOTLPHTTPDataReceiver(testbed.GetAvailablePort(t)),
testbed.ResourceSpec{
ExpectedMaxCPU: 50,
ExpectedMaxRAM: 60,
ExpectedMaxRAM: 65,
},
},
}
Expand Down