Skip to content

Commit cee04e8

Browse files
committed
feat: testing framework
1 parent c110f27 commit cee04e8

File tree

26 files changed

+260
-25
lines changed

26 files changed

+260
-25
lines changed

.github/workflows/lint.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ permissions:
1414
contents: read
1515

1616
env:
17-
PYTHON_VERSION: "3.14"
18-
CSPELL_VERSION: "8.0.0"
19-
BLACK_VERSION: "24.10.0"
20-
PRETTIER_VERSION: "3.3.3"
21-
COMMITLINT_CLI_VERSION: "20.2.0"
17+
PYTHON_VERSION: '3.14'
18+
CSPELL_VERSION: '8.0.0'
19+
BLACK_VERSION: '24.10.0'
20+
PRETTIER_VERSION: '3.3.3'
21+
COMMITLINT_CLI_VERSION: '20.2.0'
2222

2323
jobs:
2424
install-commitlint:
@@ -97,8 +97,8 @@ jobs:
9797
name: Setup Python
9898
uses: actions/setup-python@v6
9999
with:
100-
cache: "pip"
101-
python-version: "${{ env.PYTHON_VERSION }}"
100+
cache: 'pip'
101+
python-version: '${{ env.PYTHON_VERSION }}'
102102
cache-dependency-path: black-requirements.txt
103103

104104
- name: Install Black
@@ -113,7 +113,7 @@ jobs:
113113
- *setup-black
114114

115115
- name: Run Black check
116-
run: black --check .
116+
run: /usr/local/bin/black --check .
117117

118118
install-cspell:
119119
runs-on: ubuntu-latest

.github/workflows/test.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Test Actions
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
workflow_call:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
PYTHON_VERSION: '3.14'
15+
16+
jobs:
17+
python-unit-tests-actions:
18+
name: Python Unit Tests (GitHub Actions)
19+
runs-on: ubuntu-latest
20+
steps:
21+
- &checkout-code
22+
name: Checkout code
23+
uses: actions/checkout@v5
24+
25+
- &setup-python
26+
name: Setup Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ env.PYTHON_VERSION }}
30+
31+
- name: Install dependencies
32+
working-directory: actions
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -r requirements.txt
36+
37+
- name: Run unit tests
38+
working-directory: actions/update_actions
39+
run: python -m unittest discover -s . -p "test_*.py" -v
40+
41+
python-unit-tests-terraform:
42+
name: Python Unit Tests
43+
runs-on: ubuntu-latest
44+
steps:
45+
- *checkout-code
46+
- *setup-python
47+
48+
- name: Install dependencies
49+
working-directory: terraform/scripts
50+
run: |
51+
python -m pip install --upgrade pip
52+
pip install -r requirements.txt
53+
54+
- name: Run unit tests
55+
working-directory: terraform/scripts
56+
run: python -m unittest discover -s . -p "test_*.py" -v
57+
58+
test-actions:
59+
name: Test GitHub Actions Updater
60+
runs-on: ubuntu-latest
61+
steps:
62+
- *checkout-code
63+
64+
- name: Test actions updater
65+
uses: ./actions
66+
with:
67+
dry-run: 'true'
68+
file-glob: 'actions/test/.github/**/*.yml'
69+
70+
test-circleci-orbs:
71+
name: Test CircleCI Orbs Updater
72+
runs-on: ubuntu-latest
73+
steps:
74+
- *checkout-code
75+
76+
- name: Test CircleCI orbs updater
77+
uses: ./circleci-orbs
78+
with:
79+
dry-run: 'true'
80+
circleci-config-file: 'circleci-orbs/test/.circleci/config.yml'
81+
82+
test-golang:
83+
name: Test Go Dependencies Updater
84+
runs-on: ubuntu-latest
85+
steps:
86+
- *checkout-code
87+
88+
- name: Setup test fixtures
89+
run: |
90+
cp golang/test/go.mod .
91+
cp golang/test/go.sum .
92+
93+
- name: Test Go dependencies updater
94+
uses: ./golang
95+
with:
96+
dry-run: 'true'
97+
98+
test-npm:
99+
name: Test NPM Dependencies Updater
100+
runs-on: ubuntu-latest
101+
steps:
102+
- *checkout-code
103+
104+
- name: Setup test fixtures
105+
run: |
106+
cp npm/test/package.json .
107+
cp npm/test/.nvmrc .
108+
109+
- name: Test NPM dependencies updater
110+
uses: ./npm
111+
with:
112+
dry-run: 'true'
113+
114+
test-terraform:
115+
name: Test Terraform Dependencies Updater
116+
runs-on: ubuntu-latest
117+
steps:
118+
- *checkout-code
119+
120+
- name: Test Terraform dependencies updater
121+
uses: ./terraform
122+
with:
123+
dry-run: 'true'
124+
working-dir: 'terraform/test'
125+
var-file-path: 'test.tfvars'

actions/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ python cli.py --root /path/to/repo --file-glob '.github/**/*.yml' --prefixes 'ac
3737
## :gear: Inputs
3838

3939
| Input | Description | Required | Default |
40-
|------------------|-----------------------------------------------------|--------------------|-------------------------|
40+
| ---------------- | --------------------------------------------------- | ------------------ | ----------------------- |
4141
| `base-branch` | Base branch for the pull request | :white_check_mark: | `main` |
4242
| `token` | GitHub token for authentication | :x: | `${{ github.token }}` |
4343
| `branch-prefix` | Prefix for the update branch | :x: | `update-actions` |
@@ -53,8 +53,3 @@ python cli.py --root /path/to/repo --file-glob '.github/**/*.yml' --prefixes 'ac
5353
- The action requires write permissions to create branches and pull requests
5454
- GitHub CLI must be available in the runner environment
5555

56-
## :test_tube: Tests
57-
58-
```bash
59-
python -m unittest discover -s tests
60-
```

actions/action.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ inputs:
4343
description: 'Whether a successful PR should be automatically merged'
4444
default: 'false'
4545

46+
dry-run:
47+
required: false
48+
description: 'Run without creating a PR (for testing purposes)'
49+
default: 'false'
50+
4651
runs:
4752
using: 'composite'
4853
steps:
4954
- name: Checkout and setup
55+
if: inputs.dry-run != 'true'
5056
uses: alchemaxinc/composite-toolbox/checkout-and-setup@v1
5157
with:
5258
token: ${{ inputs.token }}
@@ -75,13 +81,14 @@ runs:
7581
7682
- name: Check for changes
7783
id: check_changes
84+
if: inputs.dry-run != 'true'
7885
uses: alchemaxinc/composite-toolbox/check-changes@v1
7986
with:
8087
files: '.github'
8188

8289
- name: Create Pull Request
8390
id: open-pr
84-
if: steps.check_changes.outputs.has_changes == 'true'
91+
if: inputs.dry-run != 'true' && steps.check_changes.outputs.has_changes == 'true'
8592
uses: alchemaxinc/composite-toolbox/create-pr@v1
8693
with:
8794
token: ${{ inputs.token }}
@@ -113,7 +120,7 @@ runs:
113120
*Generated by the GitHub Actions Update action* :sparkles:
114121
115122
- name: Auto-merge Pull Request
116-
if: inputs.auto-merge == 'true' && steps.open-pr.outcome == 'success'
123+
if: inputs.dry-run != 'true' && inputs.auto-merge == 'true' && steps.open-pr.outcome == 'success'
117124
uses: alchemaxinc/composite-toolbox/merge-pr@v1
118125
with:
119126
token: ${{ inputs.token }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Test Workflow
2+
3+
on: [push]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3

actions/update_actions/scanner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import yaml
88

9-
USES_PATTERN = re.compile(r"(^\s*-?\s*uses:\s*)([^@\s]+)@([^\s#]+)", re.MULTILINE)
9+
USES_PATTERN = re.compile(r"(^\s*uses:\s*)([^@\s]+)@([^\s#]+)", re.MULTILINE)
1010

1111

1212
def find_uses(obj) -> list[str]:

actions/update_actions/tests/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)