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

ci: refactor PR and dev workflows #1172

Merged
merged 7 commits into from
Jun 26, 2023
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
192 changes: 54 additions & 138 deletions .github/workflows/dev_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defaults:
shell: bash

env:
GO_VERSION: "1.20"
GO_VERSION: "1.20.5"

jobs:

Expand All @@ -25,19 +25,34 @@ jobs:
arch_os: [ 'linux_amd64' ]
steps:
- uses: actions/checkout@v3

- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
cache: false

- name: Get GOCACHE and GOMODCACHE
run: |
echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_ENV"
echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_ENV"

- uses: actions/cache/restore@v3
with:
path: |
${{ env.GOMODCACHE }}/cache
${{ env.GOCACHE }}
key: go-test-${{ env.GO_VERSION }}-${{matrix.arch_os}}-${{ hashFiles('pkg/**/go.sum', 'otelcolbuilder/.otelcol-builder.yaml') }}
restore-keys: |
go-test-${{ env.GO_VERSION }}-${{matrix.arch_os}}-

- uses: actions/cache@v3
with:
path: |
/home/runner/.cache/golangci-lint
key: ${{matrix.arch_os}}-golangcilint-${{ hashFiles('**/go.sum') }}
key: golangci-lint-${{ env.GO_VERSION }}-${{matrix.arch_os}}-${{ hashFiles('pkg/**/go.sum', 'otelcolbuilder/.otelcol-builder.yaml') }}
restore-keys: |
${{matrix.arch_os}}-golangcilint-
golangci-lint-${{ env.GO_VERSION }}-${{matrix.arch_os}}-

- name: Install golangci-lint
run: make install-golangci-lint
Expand All @@ -48,156 +63,57 @@ jobs:
- name: Run golangci-lint
run: make golint

build:
name: Build
runs-on: ${{ matrix.runs_on }}
test:
name: Test
uses: ./.github/workflows/workflow-test.yml
strategy:
matrix:
include:
- arch_os: linux_amd64
runs_on: ubuntu-20.04
- arch_os: linux_arm64
runs_on: ubuntu-20.04
runs-on: ubuntu-20.04
- arch_os: linux_amd64
runs-on: ubuntu-20.04
boringcrypto: true
- arch_os: darwin_amd64
runs_on: macos-latest
- arch_os: darwin_arm64
runs_on: macos-latest
runs-on: macos-latest
- arch_os: windows_amd64
runs_on: windows-2022
builder_bin_path: '${RUNNER_TEMP}\bin'
builder_bin_ext: .exe
steps:
- uses: actions/checkout@v3

- name: Fetch current branch
run: ./ci/fetch_current_branch.sh
runs-on: windows-2022
with:
arch_os: ${{ matrix.arch_os }}
runs-on: ${{ matrix.runs-on }}
save-cache: true
boringcrypto: ${{ matrix.boringcrypto == true }}

- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'

- name: Set default BUILDER_BIN_PATH
run: echo "BUILDER_BIN_PATH=${HOME}/bin" >> $GITHUB_ENV

- name: Override BUILDER_BIN_PATH if set in matrix
run: echo "BUILDER_BIN_PATH=${{matrix.builder_bin_path}}" >> $GITHUB_ENV
if: matrix.builder_bin_path != ''

- name: Add opentelemetry-collector-builder installation dir to PATH
run: echo "$BUILDER_BIN_PATH" >> $GITHUB_PATH

- name: Install opentelemetry-collector-builder
run: make install-builder
working-directory: ./otelcolbuilder

- name: Build
run: make otelcol-sumo-${{matrix.arch_os}}
working-directory: ./otelcolbuilder

- name: Show included modules
working-directory: ./otelcolbuilder/cmd
run: |
go version -m otelcol-sumo-${{matrix.arch_os}}${{matrix.builder_bin_ext}} | \
grep -E "/(receiver|exporter|processor|extension)/" | \
tee otelcol-sumo-${{matrix.arch_os}}_modules.txt

# TODO:
# Move that out to a separate job and run on a corresponding's OS runner.
# - name: Run the binary
# run: ./otelcol-sumo-${{matrix.arch_os}} --version
# working-directory: ./otelcolbuilder/cmd/

- name: Store binary as action artifact
uses: actions/upload-artifact@v3
with:
name: otelcol-sumo-${{matrix.arch_os}}
path: ./otelcolbuilder/cmd/otelcol-sumo-${{matrix.arch_os}}${{matrix.builder_bin_ext}}
if-no-files-found: error

- name: Store list of included modules as action artifact
uses: actions/upload-artifact@v3
with:
name: otelcol-sumo-${{matrix.arch_os}}_modules.txt
path: ./otelcolbuilder/cmd/otelcol-sumo-${{matrix.arch_os}}_modules.txt
if-no-files-found: error

# pipeline to build FIPS compliance binary on Go+BoringCrypto
build-fips:
build:
name: Build
runs-on: ubuntu-20.04
uses: ./.github/workflows/workflow-build.yml
strategy:
matrix:
arch_os: [ 'linux_amd64']
steps:
- uses: actions/checkout@v3

- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Fetch current branch
run: ./ci/fetch_current_branch.sh

# As described in
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
- uses: actions/cache@v3
with:
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
/Users/runner/go/pkg/mod
/Users/runner/Library/Caches/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Add opentelemetry-collector-builder installation dir to PATH
run: echo "$HOME/bin" >> $GITHUB_PATH

- name: Install opentelemetry-collector-builder
run: make install-builder
working-directory: ./otelcolbuilder

- name: Build
run: make otelcol-sumo-${{matrix.arch_os}} FIPS_SUFFIX="-fips" CGO_ENABLED=1
working-directory: ./otelcolbuilder

- name: Show included modules
working-directory: ./otelcolbuilder/cmd
run: |
go version -m otelcol-sumo-fips-${{matrix.arch_os}} | \
grep -E "/(receiver|exporter|processor|extension)/" | \
tee otelcol-sumo-fips-${{matrix.arch_os}}_modules.txt

- name: Show BoringSSL symbols
working-directory: ./otelcolbuilder/cmd
run: |
go tool nm otelcol-sumo-fips-${{matrix.arch_os}} | \
grep "_Cfunc__goboringcrypto_"

- name: Store binary as action artifact
uses: actions/upload-artifact@v3
with:
name: otelcol-sumo-fips-${{matrix.arch_os}}
path: ./otelcolbuilder/cmd/otelcol-sumo-fips-${{matrix.arch_os}}
if-no-files-found: error

- name: Store list of included modules as action artifact
uses: actions/upload-artifact@v3
with:
name: otelcol-sumo-fips-${{matrix.arch_os}}_modules.txt
path: ./otelcolbuilder/cmd/otelcol-sumo-fips-${{matrix.arch_os}}_modules.txt
if-no-files-found: error
include:
- arch_os: linux_amd64
runs-on: ubuntu-20.04
- arch_os: linux_amd64
runs-on: ubuntu-20.04
fips: true
- arch_os: linux_arm64
runs-on: ubuntu-20.04
- arch_os: darwin_amd64
runs-on: macos-latest
- arch_os: darwin_arm64
runs-on: macos-latest
- arch_os: windows_amd64
runs-on: windows-2022
with:
arch_os: ${{ matrix.arch_os }}
runs-on: ${{ matrix.runs-on }}
fips: ${{ matrix.fips == true }}
save-cache: true

build-container-images:
name: Build container
runs-on: ubuntu-20.04
needs:
- build
- build-fips
strategy:
matrix:
arch_os: [ 'linux_amd64', 'linux_arm64' ]
Expand Down
Loading