Skip to content

Commit

Permalink
Change build path for linux binaries to match GOARCH.
Browse files Browse the repository at this point in the history
  • Loading branch information
jefchien committed Jan 14, 2022
1 parent a849204 commit a094f16
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 187 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ jobs:
- name: Build RPM
if: steps.cached_rpms.outputs.cache-hit != 'true'
run: |
ARCH=x86_64 DEST=$PACKAGING_ROOT/linux/amd64 tools/packaging/linux/create_rpm.sh
ARCH=aarch64 DEST=$PACKAGING_ROOT/linux/arm64 tools/packaging/linux/create_rpm.sh
ARCH=x86_64 TARGET_SUPPORTED_ARCH=amd64 DEST=$PACKAGING_ROOT/linux/amd64 tools/packaging/linux/create_rpm.sh
ARCH=aarch64 TARGET_SUPPORTED_ARCH=arm64 DEST=$PACKAGING_ROOT/linux/arm64 tools/packaging/linux/create_rpm.sh
- name: Download Package Signing GPG key
if: steps.cached_rpms.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -307,8 +307,8 @@ jobs:
- name: Build Debs
if: steps.cached_debs.outputs.cache-hit != 'true'
run: |
ARCH=amd64 TARGET_SUPPORTED_ARCH=x86_64 DEST=$PACKAGING_ROOT/debian/amd64 tools/packaging/debian/create_deb.sh
ARCH=arm64 TARGET_SUPPORTED_ARCH=aarch64 DEST=$PACKAGING_ROOT/debian/arm64 tools/packaging/debian/create_deb.sh
ARCH=amd64 DEST=$PACKAGING_ROOT/debian/amd64 tools/packaging/debian/create_deb.sh
ARCH=arm64 DEST=$PACKAGING_ROOT/debian/arm64 tools/packaging/debian/create_deb.sh
- name: Download Package Signing GPG key
if: steps.cached_debs.outputs.cache-hit != 'true'
Expand Down
89 changes: 46 additions & 43 deletions .github/workflows/PR-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ jobs:
outputs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
- name: Checkout
uses: actions/checkout@v2

- name: Get updated files
id: filter
uses: dorny/paths-filter@v2
with:
list-files: shell
filters: .github/config/file-filters.yml
Expand All @@ -58,128 +61,125 @@ jobs:
steps:
# Set up building environment, patch the dev repo code on dispatch events.
- name: Set up Go 1.x
uses: actions/setup-go@v2
if: ${{ needs.changes.outputs.changed == 'true' }}
uses: actions/setup-go@v2
with:
go-version: 1.17


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

- name: Cache Build
uses: actions/cache@v2
if: ${{ needs.changes.outputs.changed == 'true' }}
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.sum') }}


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


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


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


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


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


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

- name: Download built artifacts
if: ${{ needs.changes.outputs.changed == 'true' }}
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' }}
run: ls -R

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

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

- name: restore cached binaries
- name: Restore cached binaries
if: ${{ needs.changes.outputs.changed == 'true' }}
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' }}
run: ls -R

- 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' }}
run: |
ARCH=x86_64 TARGET_SUPPORTED_ARCH=amd64 DEST=build/packages/linux/amd64 tools/packaging/linux/create_rpm.sh
ARCH=aarch64 TARGET_SUPPORTED_ARCH=arm64 DEST=build/packages/linux/arm64 tools/packaging/linux/create_rpm.sh
packaging-deb:
runs-on: ubuntu-latest
needs: [changes, build]
steps:
# Build and archive debs into cache.
- uses: actions/checkout@v2
- name: Checkout
if: ${{ needs.changes.outputs.changed == 'true' }}
uses: actions/checkout@v2

- name: restore cached binaries
- name: Restore cached binaries
if: ${{ needs.changes.outputs.changed == 'true' }}
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' }}
run: |
ARCH=amd64 DEST=build/packages/debian/amd64 tools/packaging/debian/create_deb.sh
ARCH=arm64 DEST=build/packages/debian/arm64 tools/packaging/debian/create_deb.sh
get-test-cases:
runs-on: ubuntu-latest
Expand All @@ -199,8 +199,7 @@ jobs:
echo "::set-output name=matrix::$matrix"
- name: List testing suites
run: |
echo ${{ steps.set-matrix.outputs.matrix }}
run: echo ${{ steps.set-matrix.outputs.matrix }}

run-test-case:
runs-on: ubuntu-latest
Expand All @@ -209,42 +208,46 @@ jobs:
matrix: ${{ fromJson(needs.get-test-cases.outputs.matrix) }}
steps:
- name: Check out testing framework
if: ${{ needs.changes.outputs.changed == 'true' }}
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
if: ${{ needs.changes.outputs.changed == 'true' }}
uses: actions/checkout@v2
with:
path: aws-otel-collector
if: ${{ needs.changes.outputs.changed == 'true' }}

- name: Set up JDK 11
if: ${{ needs.changes.outputs.changed == 'true' }}
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
if: ${{ needs.changes.outputs.changed == 'true' }}

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

- name: restore cached binaries
- name: Restore cached binaries
if: ${{ needs.changes.outputs.changed == 'true' }}
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
- name: Copy binary
if: ${{ needs.changes.outputs.changed == 'true' }}
run: |
cp -R build aws-otel-collector/build
ls -R aws-otel-collector/build
- name: Run test
if: ${{ needs.changes.outputs.changed == 'true' }}
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' }}
env:
DOCKER_BUILDKIT: 1 # Required for TARGETARCH to be populated with Docker compose.
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@ all-srcs:
.PHONY: build
build: install-tools lint multimod-verify
GOOS=darwin GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ./build/darwin/aoc_darwin_amd64 ./cmd/awscollector
GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ./build/linux/aoc_linux_x86_64 ./cmd/awscollector
GOOS=linux GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o ./build/linux/aoc_linux_aarch64 ./cmd/awscollector
GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ./build/linux/aoc_linux_amd64 ./cmd/awscollector
GOOS=linux GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o ./build/linux/aoc_linux_arm64 ./cmd/awscollector
GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ./build/windows/aoc_windows_amd64 ./cmd/awscollector

.PHONY: amd64-build
amd64-build: install-tools lint multimod-verify
GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ./build/linux/aoc_linux_x86_64 ./cmd/awscollector
GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ./build/linux/aoc_linux_amd64 ./cmd/awscollector

.PHONY: arm64-build
arm64-build: install-tools lint multimod-verify
GOOS=linux GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o ./build/linux/aoc_linux_aarch64 ./cmd/awscollector
GOOS=linux GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o ./build/linux/aoc_linux_arm64 ./cmd/awscollector

# For building container image during development, no lint nor other platforms
.PHONY: amd64-build-only
amd64-build-only:
GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ./build/linux/aoc_linux_x86_64 ./cmd/awscollector
GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o ./build/linux/aoc_linux_amd64 ./cmd/awscollector

.PHONY: awscollector
awscollector:
Expand All @@ -102,12 +102,12 @@ awscollector:

.PHONY: package-rpm
package-rpm: build
ARCH=x86_64 DEST=build/packages/linux/amd64 tools/packaging/linux/create_rpm.sh
ARCH=x86_64 TARGET_SUPPORTED_ARCH=amd64 DEST=build/packages/linux/amd64 tools/packaging/linux/create_rpm.sh

.PHONY: package-deb
package-deb: build
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
ARCH=amd64 DEST=build/packages/debian/amd64 tools/packaging/debian/create_deb.sh
ARCH=arm64 DEST=build/packages/debian/arm64 tools/packaging/debian/create_deb.sh

.PHONY: docker-build
docker-build: amd64-build
Expand Down
9 changes: 3 additions & 6 deletions cmd/awscollector/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ RUN apk --update add ca-certificates

WORKDIR /workspace

ARG TARGETPLATFORM
RUN echo "Target platform is $TARGETPLATFORM"
ARG TARGETARCH

# copy artifacts
# always assume binary is created
COPY build/linux/* /workspace/
COPY build/linux/aoc_linux_$TARGETARCH /workspace/awscollector
COPY config.yaml /workspace/config/otel-config.yaml
COPY config/ /workspace/config/
COPY cmd/awscollector/copy_docker_binary.sh /workspace/copy_binary.sh
RUN ./copy_binary.sh

################################
# Final Stage #
Expand All @@ -27,7 +24,7 @@ RUN ./copy_binary.sh
FROM scratch

COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /workspace/build/linux/aoc_linux /awscollector
COPY --from=build /workspace/awscollector /awscollector
COPY --from=build /workspace/config/ /etc/

ENV RUN_IN_CONTAINER="True"
Expand Down
26 changes: 0 additions & 26 deletions cmd/awscollector/copy_docker_binary.sh

This file was deleted.

2 changes: 1 addition & 1 deletion tools/packaging/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Section: admin
Depends: libc6
Priority: optional
Maintainer: Amazon.com, Inc.
Description: Amazon AWS Opentelemetry Collector
Description: Amazon AWS OpenTelemetry Collector

0 comments on commit a094f16

Please sign in to comment.