Skip to content

Commit

Permalink
Actions need to be merged to test, so isolate testing them into a bes…
Browse files Browse the repository at this point in the history
…poke action to validate env var config and that this issue is handled: actions/runner#2058
  • Loading branch information
hughesjj committed Jan 3, 2023
1 parent cb36745 commit 364b199
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/actions-test-playground.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: actions-test-playground

on:
push:
branches:
- 'test_actions*'
pull_request:
paths:
- '.github/workflows/actions-test-playground.yml'
- 'internal/buildscripts/packaging/temp-gh-actions-test/**'
- 'Makefile'

concurrency:
group: actions-test-playground-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
PYTHON_VERSION: '3.10'
PIP_VERSION: '22.0.4'
GO_VERSION: 1.19.0

jobs:
setup-environment:
name: setup-environment
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
steps:
- name: Check out the codebase.
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Caching dependency
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/go/bin
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}

- name: Test env vars
run: |
echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
echo "GITHUB_REF_NAME=$GITHUB_REF_NAME"
echo "REF_TYPE=$REF_TYPE"
echo "github ref name: ${{ github.ref_name }}"
make install-tools
make test-gh-actions
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,13 @@ endif
.PHONY: update-examples
update-examples:
cd examples && $(MAKE) update-examples

.PHONY: test-gh-actions
test-gh-actions:
echo "In makefile for github actions"
echo "$(GITHUB_WORKSPACE)"
echo "$(GITHUB_REF)"
echo "$(GITHUB_REF_NAME)"
echo "$(REF_TYPE)"
echo "$(VERSION)"
./internal/buildscripts/packaging/temp-gh-actions-test/test-gh-actions-shell-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
echo "starting tests!"
set -euxo pipefail
# Tests that github actions env vars are set as expected. Likely to fail on first few pushes, as we will be validating
# an error case to start with.

echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
echo "GITHUB_REF_NAME=$GITHUB_REF_NAME"
echo "REF_TYPE=$REF_TYPE"
echo "exiting test.."

0 comments on commit 364b199

Please sign in to comment.