Skip to content

Commit 7a5b8d6

Browse files
committed
Add test suite
1 parent 765abae commit 7a5b8d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+8517
-1034
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: Build, Test and Snapshot Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
schedule:
10+
- cron: "0 0 * * 0" # Weekly on Sunday at midnight
11+
workflow_dispatch: # Allows manual triggering
12+
13+
jobs:
14+
lint-and-test-python:
15+
name: Python Test Suite
16+
runs-on: ubuntu-latest
17+
if: github.event_name == 'pull_request' || github.event_name == 'push'
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: "3.11"
27+
28+
- name: Check if Python tests exist
29+
id: check-tests
30+
run: |
31+
if [ -f "test/requirements.txt" ] && [ -f "test/test.sh" ]; then
32+
echo "tests_exist=true" >> $GITHUB_OUTPUT
33+
echo "✅ Python test suite found"
34+
else
35+
echo "tests_exist=false" >> $GITHUB_OUTPUT
36+
echo "⚠️ Python test suite not found - skipping tests"
37+
fi
38+
39+
- name: Setup Python test environment
40+
if: steps.check-tests.outputs.tests_exist == 'true'
41+
run: |
42+
cd test
43+
python -m venv venv
44+
source venv/bin/activate
45+
python -m pip install --upgrade pip
46+
python -m pip install -r requirements.txt
47+
48+
- name: Run Python linting
49+
if: steps.check-tests.outputs.tests_exist == 'true'
50+
run: |
51+
cd testing
52+
source venv/bin/activate
53+
echo "🔍 Running flake8..."
54+
flake8 --max-line-length=120 --ignore=E203,W503 . || exit 1
55+
echo "🔍 Checking black formatting..."
56+
black --line-length=120 --check . || exit 1
57+
echo "🔍 Checking import sorting..."
58+
isort --check-only --profile=black . || exit 1
59+
echo "✅ All Python linting checks passed!"
60+
61+
- name: Run Python tests
62+
if: steps.check-tests.outputs.tests_exist == 'true'
63+
run: |
64+
cd testing
65+
source venv/bin/activate
66+
echo "🧪 Running Python tests..."
67+
pytest -v --tb=short
68+
echo "✅ Python tests completed!"
69+
70+
build:
71+
name: Build and Test Go Plugin
72+
runs-on: ${{ matrix.os }}
73+
strategy:
74+
matrix:
75+
os: [ubuntu-latest, macos-latest, windows-latest]
76+
go-version: [">=1.23.5"]
77+
78+
steps:
79+
- name: Checkout code
80+
uses: actions/checkout@v4
81+
82+
- name: Set up Go
83+
uses: actions/setup-go@v5
84+
with:
85+
go-version: ${{ matrix.go-version }}
86+
87+
- name: Install dependencies
88+
run: go mod tidy -e || true
89+
90+
- name: Lint Go files
91+
run: |
92+
echo "🔍 Running go fmt..."
93+
go fmt .
94+
echo "🔍 Running go vet..."
95+
go vet .
96+
97+
- name: Build binary
98+
run: |
99+
echo "🔨 Building binary..."
100+
python3 .github/workflows/build.py
101+
102+
- name: Upload artifact
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: cf-cli-java-plugin-${{ matrix.os }}
106+
path: dist/
107+
108+
release:
109+
name: Create Snapshot Release
110+
needs: [build, lint-and-test-python]
111+
runs-on: ubuntu-latest
112+
if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && (needs.lint-and-test-python.result == 'success' || needs.lint-and-test-python.result == 'skipped')
113+
114+
steps:
115+
- name: Download all artifacts
116+
uses: actions/download-artifact@v4
117+
with:
118+
path: dist/
119+
120+
- name: Combine all artifacts
121+
run: |
122+
mkdir -p dist
123+
mv dist/*/* dist/ || true
124+
125+
- uses: thomashampson/delete-older-releases@main
126+
with:
127+
keep_latest: 0
128+
delete_tag_regex: snapshot
129+
prerelease_only: true
130+
delete_tags: true
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
134+
- name: Create GitHub Release
135+
uses: softprops/action-gh-release@v1
136+
with:
137+
files: dist/*
138+
prerelease: false
139+
release: false
140+
tag_name: snapshot
141+
body: |
142+
This is a snapshot release of the cf-cli-java-plugin.
143+
It includes the latest changes and is not intended for production use.
144+
Please test it and provide feedback.
145+
146+
## Build Status
147+
- ✅ Go Plugin: Built and tested on Linux, macOS, and Windows
148+
- ✅ Python Tests: Linting and test suite validation completed
149+
150+
## Changes
151+
This snapshot includes the latest commits from the repository.
152+
name: Snapshot Release
153+
env:
154+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 69 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Snapshot Release
1+
name: Build, Test and Snapshot Release
22

33
on:
44
push:
@@ -7,12 +7,66 @@ on:
77
- master
88
pull_request:
99
schedule:
10-
- cron: '0 0 * * 0' # Weekly on Sunday at midnight
10+
- cron: "0 0 * * 0" # Weekly on Sunday at midnight
1111
workflow_dispatch: # Allows manual triggering
1212

1313
jobs:
14+
lint-and-test-python:
15+
name: Python Test Suite
16+
runs-on: ubuntu-latest
17+
if: github.event_name == 'pull_request' || github.event_name == 'push'
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: "3.11"
27+
28+
- name: Check if Python tests exist
29+
id: check-tests
30+
run: |
31+
if [ -f "test/requirements.txt" ] && [ -f "test/setup.sh" ]; then
32+
echo "tests_exist=true" >> $GITHUB_OUTPUT
33+
echo "✅ Python test suite found"
34+
else
35+
echo "tests_exist=false" >> $GITHUB_OUTPUT
36+
echo "⚠️ Python test suite not found - skipping tests"
37+
fi
38+
39+
- name: Setup Python test environment
40+
if: steps.check-tests.outputs.tests_exist == 'true'
41+
run: |
42+
cd test
43+
python -m venv venv
44+
source venv/bin/activate
45+
python -m pip install --upgrade pip
46+
python -m pip install -r requirements.txt
47+
48+
- name: Run Python linting
49+
if: steps.check-tests.outputs.tests_exist == 'true'
50+
run: ./scripts/lint-python.sh ci
51+
52+
# TODO: Re-enable Python tests when ready
53+
# - name: Run Python tests
54+
# if: steps.check-tests.outputs.tests_exist == 'true'
55+
# run: |
56+
# cd test
57+
# source venv/bin/activate
58+
# echo "🧪 Running Python tests..."
59+
# pytest -v --tb=short
60+
# echo "✅ Python tests completed!"
61+
# env:
62+
# CF_API: ${{ secrets.CF_API }}
63+
# CF_USERNAME: ${{ secrets.CF_USERNAME }}
64+
# CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
65+
# CF_ORG: ${{ secrets.CF_ORG }}
66+
# CF_SPACE: ${{ secrets.CF_SPACE }}
67+
1468
build:
15-
name: Build and Test on All Platforms
69+
name: Build and Test Go Plugin
1670
runs-on: ${{ matrix.os }}
1771
strategy:
1872
matrix:
@@ -21,30 +75,24 @@ jobs:
2175

2276
steps:
2377
- name: Checkout code
24-
uses: actions/checkout@v3
78+
uses: actions/checkout@v4
2579

2680
- name: Set up Go
2781
uses: actions/setup-go@v5
2882
with:
2983
go-version: ${{ matrix.go-version }}
3084

31-
- name: Set up Python
32-
uses: actions/setup-python@v4
33-
with:
34-
python-version: '3.x'
35-
3685
- name: Install dependencies
3786
run: go mod tidy -e || true
3887

3988
- name: Lint Go files
40-
run: go fmt ./...
41-
42-
- name: Run Go tests
43-
run: go test
89+
run: ./scripts/lint-go.sh check
4490

4591
- name: Build binary
46-
run: python3 .github/workflows/build.py
47-
92+
run: |
93+
echo "🔨 Building binary..."
94+
python3 .github/workflows/build.py
95+
4896
- name: Upload artifact
4997
uses: actions/upload-artifact@v4
5098
with:
@@ -53,21 +101,21 @@ jobs:
53101

54102
release:
55103
name: Create Snapshot Release
56-
needs: build
104+
needs: [build, lint-and-test-python]
57105
runs-on: ubuntu-latest
58-
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
106+
if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && (needs.lint-and-test-python.result == 'success' || needs.lint-and-test-python.result == 'skipped')
59107

60108
steps:
61109
- name: Download all artifacts
62110
uses: actions/download-artifact@v4
63111
with:
64-
path: dist/ # Specify the directory where artifacts will be downloaded
112+
path: dist/
65113

66114
- name: Combine all artifacts
67115
run: |
68116
mkdir -p dist
69117
mv dist/*/* dist/ || true
70-
118+
71119
- uses: thomashampson/delete-older-releases@main
72120
with:
73121
keep_latest: 0
@@ -88,6 +136,7 @@ jobs:
88136
This is a snapshot release of the cf-cli-java-plugin.
89137
It includes the latest changes and is not intended for production use.
90138
Please test it and provide feedback.
139+
91140
name: Snapshot Release
92141
env:
93-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
142+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Build and Snapshot Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
schedule:
10+
- cron: '0 0 * * 0' # Weekly on Sunday at midnight
11+
workflow_dispatch: # Allows manual triggering
12+
13+
jobs:
14+
build:
15+
name: Build and Test on All Platforms
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest, macos-latest, windows-latest]
20+
go-version: [">=1.23.5"]
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v3
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version: ${{ matrix.go-version }}
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v4
33+
with:
34+
python-version: '3.x'
35+
36+
- name: Install dependencies
37+
run: go mod tidy -e || true
38+
39+
- name: Lint Go files
40+
run: go fmt ./...
41+
42+
- name: Run Go tests
43+
run: go test
44+
45+
- name: Build binary
46+
run: python3 .github/workflows/build.py
47+
48+
- name: Upload artifact
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: cf-cli-java-plugin-${{ matrix.os }}
52+
path: dist/
53+
54+
release:
55+
name: Create Snapshot Release
56+
needs: build
57+
runs-on: ubuntu-latest
58+
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
59+
60+
steps:
61+
- name: Download all artifacts
62+
uses: actions/download-artifact@v4
63+
with:
64+
path: dist/ # Specify the directory where artifacts will be downloaded
65+
66+
- name: Combine all artifacts
67+
run: |
68+
mkdir -p dist
69+
mv dist/*/* dist/ || true
70+
71+
- uses: thomashampson/delete-older-releases@main
72+
with:
73+
keep_latest: 0
74+
delete_tag_regex: snapshot
75+
prerelease_only: true
76+
delete_tags: true
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
80+
- name: Create GitHub Release
81+
uses: softprops/action-gh-release@v1
82+
with:
83+
files: dist/*
84+
prerelease: false
85+
release: false
86+
tag_name: snapshot
87+
body: |
88+
This is a snapshot release of the cf-cli-java-plugin.
89+
It includes the latest changes and is not intended for production use.
90+
Please test it and provide feedback.
91+
name: Snapshot Release
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)