Skip to content

Commit e0665b3

Browse files
committed
Add CLI integration tests workflow to trigger jfrog-cli tests from artifactory PRs
1 parent 12090b4 commit e0665b3

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# This workflow runs jfrog-cli integration tests against changes in jfrog-cli-artifactory.
2+
# It allows validating that changes to this module don't break the CLI without creating a PR on jfrog-cli.
3+
#
4+
# How it works:
5+
# 1. Clones jfrog-cli repository
6+
# 2. Replaces the jfrog-cli-artifactory dependency with the PR branch using go mod replace
7+
# 3. Installs a local Artifactory instance
8+
# 4. Runs the specified CLI integration tests
9+
#
10+
# Trigger:
11+
# - Automatically on every push to a PR branch targeting main
12+
# - On push to main
13+
# - Manual dispatch for specific test suites
14+
name: CLI Integration Tests
15+
on:
16+
workflow_dispatch:
17+
inputs:
18+
test_suite:
19+
description: 'Test suite to run (artifactory, npm, maven, gradle, go, conan, helm, nuget, pip, docker)'
20+
required: false
21+
default: 'artifactory'
22+
type: choice
23+
options:
24+
- artifactory
25+
- npm
26+
- maven
27+
- gradle
28+
- go
29+
- conan
30+
- helm
31+
- nuget
32+
- pip
33+
- docker
34+
jfrog_cli_branch:
35+
description: 'jfrog-cli branch to test against (default: master)'
36+
required: false
37+
default: 'master'
38+
type: string
39+
push:
40+
branches:
41+
- "main"
42+
# Triggers on every push to PR branches targeting main
43+
pull_request:
44+
branches:
45+
- "main"
46+
47+
# Ensures that only the latest commit is running for each PR at a time.
48+
concurrency:
49+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.ref }}
50+
cancel-in-progress: true
51+
52+
jobs:
53+
CLI-Integration-Tests:
54+
name: CLI ${{ matrix.suite }} Tests (${{ matrix.os.name }})
55+
# Runs on: manual dispatch, push to main, or any push to a PR branch
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
suite: ${{ github.event_name == 'workflow_dispatch' && fromJSON(format('["{0}"]', inputs.test_suite)) || fromJSON('["artifactory"]') }}
60+
os:
61+
- name: ubuntu
62+
version: 24.04
63+
runs-on: ${{ matrix.os.name }}-${{ matrix.os.version }}
64+
env:
65+
JFROG_CLI_LOG_LEVEL: DEBUG
66+
GOPROXY: direct
67+
steps:
68+
- name: Checkout jfrog-cli-artifactory (this repo - your PR branch)
69+
uses: actions/checkout@v5
70+
with:
71+
# For pull_request events, this checks out the PR head (your changes)
72+
# For push events, this checks out the pushed commit
73+
path: jfrog-cli-artifactory
74+
75+
- name: Checkout jfrog-cli
76+
uses: actions/checkout@v5
77+
with:
78+
repository: jfrog/jfrog-cli
79+
ref: ${{ inputs.jfrog_cli_branch || 'master' }}
80+
path: jfrog-cli
81+
82+
- name: Setup Go with cache
83+
uses: jfrog/.github/actions/install-go-with-cache@main
84+
85+
# Replace jfrog-cli-artifactory dependency with the PR version
86+
- name: Replace jfrog-cli-artifactory dependency
87+
working-directory: jfrog-cli
88+
run: |
89+
echo "Replacing jfrog-cli-artifactory with local version from PR..."
90+
91+
# Get the absolute path to the checked out jfrog-cli-artifactory
92+
ARTIFACTORY_PATH=$(cd ../jfrog-cli-artifactory && pwd)
93+
94+
# Add replace directive to go.mod
95+
echo "" >> go.mod
96+
echo "replace github.com/jfrog/jfrog-cli-artifactory => ${ARTIFACTORY_PATH}" >> go.mod
97+
98+
echo "Updated go.mod with replace directive:"
99+
tail -5 go.mod
100+
101+
# Update dependencies
102+
go mod tidy
103+
104+
- name: Verify dependency replacement
105+
working-directory: jfrog-cli
106+
run: |
107+
echo "Verifying go.mod..."
108+
cat go.mod | grep -A2 "jfrog-cli-artifactory" || echo "Dependency found"
109+
echo ""
110+
echo "Running go mod graph for jfrog-cli-artifactory..."
111+
go mod graph | grep "jfrog-cli-artifactory" | head -5 || echo "Dependency in graph"
112+
113+
- name: Install local Artifactory
114+
uses: jfrog/.github/actions/install-local-artifactory@main
115+
with:
116+
RTLIC: ${{ secrets.RTLIC }}
117+
RT_CONNECTION_TIMEOUT_SECONDS: '1200'
118+
119+
- name: Run CLI Integration Tests
120+
working-directory: jfrog-cli
121+
run: |
122+
echo "Running ${{ matrix.suite }} tests..."
123+
go test -v github.com/jfrog/jfrog-cli --timeout 0 \
124+
--test.${{ matrix.suite }} \
125+
--jfrog.url=http://127.0.0.1:8082 \
126+
--jfrog.adminToken=${{ env.JFROG_TESTS_LOCAL_ACCESS_TOKEN }} \
127+
--ci.runId=${{ runner.os }}-${{ matrix.suite }}-artifactory-pr

0 commit comments

Comments
 (0)