Skip to content

Commit c8e4e73

Browse files
committed
Actions need to be merged to test, so isolate testing them into a bespoke action to validate env var config and that this issue is handled: actions/runner#2058
1 parent cb36745 commit c8e4e73

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: actions-test-playground
2+
3+
on:
4+
push:
5+
branches:
6+
- 'test_actions*'
7+
pull_request:
8+
paths:
9+
- '.github/workflows/actions-test-playground.yml'
10+
- 'internal/buildscripts/packaging/temp-gh-actions-test/**'
11+
- 'Makefile'
12+
13+
concurrency:
14+
group: actions-test-playground-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
17+
env:
18+
PYTHON_VERSION: '3.10'
19+
PIP_VERSION: '22.0.4'
20+
GO_VERSION: 1.19.0
21+
22+
jobs:
23+
setup-environment:
24+
name: setup-environment
25+
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
26+
runs-on: ubuntu-20.04
27+
steps:
28+
- name: Check out the codebase.
29+
uses: actions/checkout@v3
30+
31+
- name: Set up Go
32+
uses: actions/setup-go@v3
33+
with:
34+
go-version: ${{ env.GO_VERSION }}
35+
36+
- name: Caching dependency
37+
uses: actions/cache@v3
38+
with:
39+
path: |
40+
~/.cache/go-build
41+
~/go/pkg/mod
42+
~/go/bin
43+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
44+
45+
- name: Test env vars
46+
run: |
47+
echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
48+
echo "GITHUB_REF_NAME=$GITHUB_REF_NAME"
49+
echo "GITHUB_REF_TYPE=$GITHUB_REF_TYPE"
50+
echo "github ref name: ${{ github.ref_name }}"
51+
echo "github ref type: ${{ github.ref_type }}"
52+
make install-tools
53+
make test-gh-actions
54+
echo "back to testing workflow yaml"
55+
echo "github ref name: ${{ github.ref_name }}"
56+
echo "github ref type: ${{ github.ref_type }}"
57+
echo "github workspace: ${{ github.workspace }}"
58+
echo "github ref: ${{ github.ref }}"
59+
echo "github env: ${{ github.env }}"
60+
echo "github env workspace: ${{ env.GITHUB_WORKSPACE }}"
61+
- name: Test env vars
62+
if: ${{ github.ref_type == "tag" }}
63+
run: |
64+
echo "HEY THIS IS A TAGGED COMMIT"
65+
echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
66+
echo "GITHUB_REF_NAME=$GITHUB_REF_NAME"
67+
echo "GITHUB_REF_TYPE=$GITHUB_REF_TYPE"
68+
echo "github ref name: ${{ github.ref_name }}"
69+
echo "github ref type: ${{ github.ref_type }}"
70+
make install-tools
71+
make test-gh-actions
72+
echo "back to testing workflow yaml"
73+
echo "github ref name: ${{ github.ref_name }}"
74+
echo "github ref type: ${{ github.ref_type }}"
75+
echo "github workspace: ${{ github.workspace }}"
76+
echo "github ref: ${{ github.ref }}"
77+
echo "github env: ${{ github.env }}"
78+
echo "github env workspace: ${{ env.GITHUB_WORKSPACE }}"

Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,14 @@ endif
225225
.PHONY: update-examples
226226
update-examples:
227227
cd examples && $(MAKE) update-examples
228+
229+
.PHONY: test-gh-actions
230+
test-gh-actions:
231+
echo "In makefile for github actions"
232+
echo "GITHUB_WORKSPACE=$(GITHUB_WORKSPACE)"
233+
echo "GITHUB_REF=$(GITHUB_REF)"
234+
echo "GITHUB_REF_NAME=$(GITHUB_REF_NAME)"
235+
echo "GITHUB_REF_TYPE=$(GITHUB_REF_TYPE)"
236+
echo "VERSION=$(VERSION)"
237+
echo "calling to external script"
238+
./internal/buildscripts/packaging/temp-gh-actions-test/test-gh-actions-shell-script.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
echo "starting tests!"
3+
set -euxo pipefail
4+
# Tests that github actions env vars are set as expected. Likely to fail on first few pushes, as we will be validating
5+
# an error case to start with.
6+
7+
echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
8+
echo "GITHUB_REF_NAME=$GITHUB_REF_NAME"
9+
echo "GITHUB_REF_TYPE=$GITHUB_REF_TYPE"
10+
echo "exiting test.."

0 commit comments

Comments
 (0)