Skip to content

Commit 41c908e

Browse files
authored
Add run tests action (redis#3221)
* Added run-tests action and used in tests workflow * Added otel-authorization-token input to run-tests * Change redis-version input to non-required * Add run-codecov input and codecov and otel logic
1 parent 17b8b41 commit 41c908e

2 files changed

Lines changed: 79 additions & 33 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: 'Run node-redis tests'
2+
description: 'Runs node-redis tests against different Redis versions and configurations'
3+
inputs:
4+
repository:
5+
description: 'Repository to checkout'
6+
required: false
7+
ref:
8+
description: 'Branch to checkout'
9+
required: false
10+
node-version:
11+
description: 'Node version to use for running tests'
12+
required: true
13+
redis-tag:
14+
description: 'Redis image tag'
15+
required: false
16+
redis-version:
17+
description: 'Redis version to test against'
18+
required: false
19+
otel-authorization-token:
20+
description: 'Authorization token for OTEL metrics reporting'
21+
required: false
22+
run-codecov:
23+
description: 'Whether to upload coverage to Codecov'
24+
required: false
25+
default: 'true'
26+
runs:
27+
using: "composite"
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
repository: ${{ inputs.repository }}
32+
ref: ${{ inputs.ref }}
33+
fetch-depth: 1
34+
- name: Use Node.js ${{ inputs.node-version }}
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: ${{ inputs.node-version }}
38+
- name: Update npm
39+
shell: bash
40+
run: npm i -g npm
41+
if: ${{ inputs.node-version <= 14 }}
42+
- name: Install Packages
43+
shell: bash
44+
run: npm ci
45+
- name: Build
46+
shell: bash
47+
run: npm run build
48+
- name: Run Tests
49+
shell: bash
50+
run: npm run test -ws --if-present -- --forbid-only --redis-tag=${{ inputs.redis-tag }} --redis-version=${{ inputs.redis-version }}
51+
- name: Upload to Codecov
52+
if: inputs.run-codecov == 'true'
53+
shell: bash
54+
run: |
55+
curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
56+
curl -Os https://uploader.codecov.io/latest/linux/codecov
57+
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
58+
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
59+
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
60+
shasum -a 256 -c codecov.SHA256SUM
61+
chmod +x codecov
62+
./codecov
63+
- name: Self Report Metrics
64+
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && inputs.otel-authorization-token != ''
65+
id: self-report-metrics
66+
uses: redis-developer/cae-otel-ci-visibility@v2
67+
with:
68+
junit-xml-folder: "junit-results"
69+
otlp-endpoint: "https://otlp-gateway-prod-us-central-0.grafana.net/otlp/v1/metrics"
70+
otlp-headers: "Authorization=Basic ${{inputs.otel-authorization-token}}"
71+
env:
72+
OTEL_EXPORTER_OTLP_PROTOCOL: "http/protobuf"
73+
ACTIONS_STEP_DEBUG: "true"

.github/workflows/tests.yml

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,10 @@ jobs:
3535
- uses: actions/checkout@v4
3636
with:
3737
fetch-depth: 1
38-
- name: Use Node.js ${{ matrix.node-version }}
39-
uses: actions/setup-node@v4
38+
- name: Run tests
39+
uses: ./.github/actions/run-tests
4040
with:
41-
node-version: ${{ matrix.node-version }}
42-
- name: Update npm
43-
run: npm i -g npm
44-
if: ${{ matrix.node-version <= 14 }}
45-
- name: Install Packages
46-
run: npm ci
47-
- name: Build
48-
run: npm run build
49-
- name: Run Tests
50-
run: npm run test -ws --if-present -- --forbid-only --redis-tag=${{ matrix.redis.tag }} --redis-version=${{ matrix.redis.version }}
51-
- name: Upload to Codecov
52-
run: |
53-
curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
54-
curl -Os https://uploader.codecov.io/latest/linux/codecov
55-
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
56-
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
57-
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
58-
shasum -a 256 -c codecov.SHA256SUM
59-
chmod +x codecov
60-
./codecov
61-
- name: Self Report Metrics
62-
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
63-
id: self-report-metrics
64-
uses: redis-developer/cae-otel-ci-visibility@v2
65-
with:
66-
junit-xml-folder: "junit-results"
67-
otlp-endpoint: "https://otlp-gateway-prod-us-central-0.grafana.net/otlp/v1/metrics"
68-
otlp-headers: "Authorization=Basic ${{secrets.SELF_CHECK_OTEL_AUTHORIZATION_TOKEN}}"
69-
env:
70-
OTEL_EXPORTER_OTLP_PROTOCOL: "http/protobuf"
71-
ACTIONS_STEP_DEBUG: "true"
41+
node-version: ${{ matrix.node-version }}
42+
redis-tag: ${{ matrix.redis.tag }}
43+
redis-version: ${{ matrix.redis.version }}
44+
otel-authorization-token: ${{ secrets.SELF_CHECK_OTEL_AUTHORIZATION_TOKEN }}

0 commit comments

Comments
 (0)