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 e9ff479
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/actions-test-playground.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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 }}"
echo "github ref type: ${{ payload.ref_type }}"
echo "github ref type: ${{ payload.ref_type }}"
make install-tools
make test-gh-actions
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,17 @@ 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
# Would be surprised if these worked at all
echo "github ref name: ${{ github.ref_name }}"
echo "github ref type: ${{ payload.ref_type }}"
echo "github ref type: ${{ payload.ref_type }}"
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 e9ff479

Please sign in to comment.