-
Notifications
You must be signed in to change notification settings - Fork 1
116 lines (113 loc) · 3.89 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Tests
on:
push:
branches: [ main ]
paths:
- 'dist/*.js'
- '.github/workflows/tests.yml'
pull_request:
branches: [ main ]
jobs:
test:
name: Test Action
strategy:
matrix:
os:
- macos-12
- macos-13
- macos-14
- macos-latest
- ubuntu-20.04
- ubuntu-22.04
- ubuntu-latest
- windows-2019
- windows-2022
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Generate action code
if: ${{ github.event_name == 'pull_request' }}
uses: ./.github/actions/generate-action-code
- uses: sersoft-gmbh/os-version-action@main
if: ${{ github.event_name == 'push' }}
id: os-version-main
- uses: './'
if: ${{ github.event_name == 'pull_request' }}
id: os-version-local
- id: os-version
env:
EVENT_NAME: ${{ github.event_name }}
BRANCH_VERSION: ${{ steps.os-version-main.outputs.version }}
LOCAL_VERSION: ${{ steps.os-version-local.outputs.version }}
run: |
if [ "${EVENT_NAME}" == 'push' ]; then
echo "version=${BRANCH_VERSION}" >> "${GITHUB_OUTPUT}"
else
echo "version=${LOCAL_VERSION}" >> "${GITHUB_OUTPUT}"
fi
shell: bash
- name: Check for reported version
if: ${{ runner.os == 'Linux' }}
env:
DETECTED_VERSION: ${{ steps.os-version.outputs.version }}
run: lsb_release -sr | grep -q "${DETECTED_VERSION}"
shell: bash
- name: Check for reported version
if: ${{ runner.os == 'macOS' }}
env:
DETECTED_VERSION: ${{ steps.os-version.outputs.version }}
run: sw_vers -productVersion | grep -q "${DETECTED_VERSION}"
shell: bash
- name: Check for reported version
if: ${{ runner.os == 'Windows' }}
env:
DETECTED_VERSION: ${{ steps.os-version.outputs.version }}
run: |
EXPECTED_VERSION=$(systeminfo | grep -oE '^OS Name: +[A-Za-z0-9 .]+' | grep -oE '[0-9.]+')
if [ "${EXPECTED_VERSION}" = '' ]; then
EXPECTED_VERSION="$(pwsh -Command '[System.Environment]::OSVersion.Version.Major').$(pwsh -Command '[System.Environment]::OSVersion.Version.Minor')"
fi
echo "Expecting: ${EXPECTED_VERSION}"
echo "${EXPECTED_VERSION}" | grep -q "${DETECTED_VERSION}"
shell: bash
test-container:
name: Test Action using Container
runs-on: ubuntu-latest
strategy:
matrix:
container: # Ubuntu containers don't have `lsb_release` installed
- ubuntu:20.04
- ubuntu:22.04
- ubuntu:23.04
- ubuntu:23.10
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v4
- name: Generate action code
if: ${{ github.event_name == 'pull_request' }}
uses: ./.github/actions/generate-action-code
- uses: sersoft-gmbh/os-version-action@main
if: ${{ github.event_name == 'push' }}
id: os-version-main
- uses: './'
if: ${{ github.event_name == 'pull_request' }}
id: os-version-local
- id: os-version
env:
EVENT_NAME: ${{ github.event_name }}
BRANCH_VERSION: ${{ steps.os-version-main.outputs.version }}
LOCAL_VERSION: ${{ steps.os-version-local.outputs.version }}
run: |
if [ "${EVENT_NAME}" == 'push' ]; then
echo "version=${BRANCH_VERSION}" >> "${GITHUB_OUTPUT}"
else
echo "version=${LOCAL_VERSION}" >> "${GITHUB_OUTPUT}"
fi
shell: bash
- name: Check for reported version
env:
CONTAINER: ${{ matrix.container }}
DETECTED_VERSION: ${{ steps.os-version.outputs.version }}
run: test "${DETECTED_VERSION}" = "${CONTAINER#*:}"
shell: bash