Skip to content

Commit

Permalink
Merge branch 'aws-observability:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard To authored Nov 10, 2021
2 parents 899b7f6 + 457a1b0 commit 7bc592f
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 24 deletions.
14 changes: 14 additions & 0 deletions .github/config/file-filters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
changed:
- '.github/workflows/PR-build.yml'
- 'cmd/**'
- 'config/**'
- 'deployment-template/**'
- 'e2etest/**'
- 'pkg/**'
- 'tools/**'
- 'Makefile'
- 'go.sum'
all:
- '**'
version:
- 'VERSION'
4 changes: 4 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ on:
- main
- release-branch-v*
- dev
paths-ignore:
- '.github/**'
- '!.github/workflows/CI.yml'
- '**.md'

# from collector and contrib repo
repository_dispatch:
Expand Down
86 changes: 62 additions & 24 deletions .github/workflows/PR-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,41 @@ concurrency:
cancel-in-progress: true

jobs:
build:
changes:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: filter
with:
list-files: shell
filters: .github/config/file-filters.yml

- name: List all updated files
run: |
for file in ${{ steps.filter.outputs.all_files }}; do
echo "$file"
done
- name: Check if this is a version bump PR
if: steps.filter.outputs.version == 'true'
run: echo "This is a version bump PR!"

build:
runs-on: ubuntu-latest
needs: changes
steps:
# Set up building environment, patch the dev repo code on dispatch events.
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.17
if: ${{ needs.changes.outputs.changed == 'true' }}

- uses: actions/checkout@v2
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Cache Build
uses: actions/cache@v2
Expand All @@ -47,125 +71,133 @@ jobs:
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
if: ${{ needs.changes.outputs.changed == 'true' }}

# Unit Test and attach test coverage badge
- name: Unit Test
run: make test
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Upload Coverage report to CodeCov
uses: codecov/codecov-action@v1.0.12
with:
file: ./coverage.txt
if: ${{ needs.changes.outputs.changed == 'true' }}

# Build and archive binaries into cache.
- name: Build Binaries
run: make build
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Cache binaries
uses: actions/cache@v2
with:
key: "cached_binaries_${{ github.run_id }}"
path: build
if: ${{ needs.changes.outputs.changed == 'true' }}

# upload the binaries to artifact as well because cache@v2 hasn't support windows
- name: Upload
uses: actions/upload-artifact@v2
with:
name: binary_artifacts
path: build
if: ${{ needs.changes.outputs.changed == 'true' }}

analyze:
name: CodeQL Analyze
runs-on: ubuntu-latest

needs: changes
steps:
- uses: actions/checkout@v2
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: "go"
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
if: ${{ needs.changes.outputs.changed == 'true' }}

packaging-msi:
needs: build
runs-on: windows-latest
needs: [changes, build]
steps:
- uses: actions/checkout@v2
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Download built artifacts
uses: actions/download-artifact@v2
with:
name: binary_artifacts
path: build
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Display structure of downloaded files
run: ls -R
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Create msi file using candle and light
run: .\tools\packaging\windows\create_msi.ps1
if: ${{ needs.changes.outputs.changed == 'true' }}

packaging-rpm:
runs-on: ubuntu-latest
needs: build
needs: [changes, build]
steps:
# Build and archive rpms into cache.
# Build and archive RPMs into cache.
- uses: actions/checkout@v2
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: restore cached binaries
uses: actions/cache@v2
with:
key: "cached_binaries_${{ github.run_id }}"
path: build
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Display structure of downloaded files
run: ls -R
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Build RPM
run: |
ARCH=x86_64 DEST=build/packages/linux/amd64 tools/packaging/linux/create_rpm.sh
ARCH=aarch64 DEST=build/packages/linux/arm64 tools/packaging/linux/create_rpm.sh
if: ${{ needs.changes.outputs.changed == 'true' }}

packaging-deb:
runs-on: ubuntu-latest
needs: build
needs: [changes, build]
steps:
# Build and archive debs into cache.
- uses: actions/checkout@v2
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: restore cached binaries
uses: actions/cache@v2
with:
key: "cached_binaries_${{ github.run_id }}"
path: build
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Build Debs
run: |
ARCH=amd64 TARGET_SUPPORTED_ARCH=x86_64 DEST=build/packages/debian/amd64 tools/packaging/debian/create_deb.sh
ARCH=arm64 TARGET_SUPPORTED_ARCH=aarch64 DEST=build/packages/debian/arm64 tools/packaging/debian/create_deb.sh
if: ${{ needs.changes.outputs.changed == 'true' }}

get-test-cases:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v2

- id: file_changes
uses: trilom/file-changes-action@v1.2.4
with:
fileOutput: ''

- name: Get the updated files
run: echo ${{ steps.file_changes.outputs.files_modified }}

- name: Check if this is a version bump pr
if: contains(steps.file_changes.outputs.files_modified, 'VERSION')
run: echo "this is a version bump pr!"


- name: Setup Python
uses: actions/setup-python@v2.1.4

Expand All @@ -181,40 +213,46 @@ jobs:
run-test-case:
runs-on: ubuntu-latest
needs: [get-test-cases, build]
needs: [changes, get-test-cases, build]
strategy:
matrix: ${{ fromJson(needs.get-test-cases.outputs.matrix) }}

steps:
- name: Check out testing framework
uses: actions/checkout@v2
with:
repository: 'aws-observability/aws-otel-collector-test-framework'
path: testing-framework
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Check out Collector
uses: actions/checkout@v2
with:
path: aws-otel-collector

if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11

if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Set up terraform
uses: hashicorp/setup-terraform@v1.2.1
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: restore cached binaries
uses: actions/cache@v2
with:
key: "cached_binaries_${{ github.run_id }}"
path: build
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: copy binary
run: cp -R build aws-otel-collector/build
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Run test
run: |
if [[ -f testing-framework/terraform/testcases/${{ matrix.testcase }}/parameters.tfvars ]] ; then opts="-var-file=../testcases/${{ matrix.testcase }}/parameters.tfvars" ; else opts="" ; fi
cd testing-framework/terraform/mock && terraform init && terraform apply -auto-approve -var="testcase=../testcases/${{ matrix.testcase }}" $opts
if: ${{ needs.changes.outputs.changed == 'true' }}

0 comments on commit 7bc592f

Please sign in to comment.