-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (104 loc) · 3.4 KB
/
test_install.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
name: "🚀 Test Cloudsmith CLI Installer"
on:
workflow_dispatch:
push:
permissions:
id-token: write
contents: read
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest # 🐧
- macos-latest # 🍏
- windows-latest # 🪟
install-method: [pip, executable]
auth-method: [oidc, api-key]
steps:
- uses: actions/checkout@v4
- name: "Set up Node.js"
uses: actions/setup-node@v4
with:
node-version: "20"
- name: "Install dependencies"
run: npm install
- name: "Build project"
run: npm run build
- name: "📦 Run Cloudsmith CLI Installer"
uses: ./
with:
api-user-agent: "gha-test"
oidc-namespace: ${{ matrix.auth-method == 'oidc' && vars.NAMESPACE || '' }}
oidc-service-slug: ${{ matrix.auth-method == 'oidc' && vars.SERVICE_ACCOUNT || '' }}
pip-install: ${{ matrix.install-method == 'pip' }}
api-key: ${{ matrix.auth-method == 'api-key' && secrets.CLOUDSMITH_API_KEY || '' }}
- name: "🔍 Verify Cloudsmith CLI Authentication (Linux and macOS)"
if: runner.os != 'Windows'
run: |
cloudsmith whoami
shell: bash
- name: "🔍 Verify Cloudsmith CLI Authentication (Windows)"
if: runner.os == 'Windows'
run: |
cloudsmith whoami
shell: cmd
- name: "📄 Read Config File (Linux and macOS)"
if: runner.os != 'Windows'
run: |
CONFIG_FILE="$HOME/.cloudsmith/config.ini"
if [ -f "$CONFIG_FILE" ]; then
echo "Config file contents:"
cat "$CONFIG_FILE"
else
echo "Config file not found at $CONFIG_FILE"
fi
shell: bash
- name: "📄 Read Config File (Windows)"
if: runner.os == 'Windows'
run: |
$configFile = "$env:LOCALAPPDATA\cloudsmith\config.ini"
if (!(Test-Path $configFile)) {
$configFile = "$env:APPDATA\cloudsmith\config.ini"
}
if (Test-Path $configFile) {
Write-Output "Config file contents:"
Get-Content $configFile
} else {
Write-Output "Config file not found at $configFile"
}
shell: pwsh
test-oidc-only:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Set up Node.js"
uses: actions/setup-node@v4
with:
node-version: "20"
- name: "Install dependencies"
run: npm install
- name: "Build project"
run: npm run build
- name: OIDC Authentication Only
uses: ./
with:
oidc-namespace: ${{ vars.NAMESPACE }}
oidc-service-slug: ${{ vars.SERVICE_ACCOUNT }}
oidc-auth-only: 'true'
- name: Test Authentication
run: |
curl -X GET \
-H "Authorization: Bearer $CLOUDSMITH_API_KEY" \
https://api.cloudsmith.io/v1/user/self/ \
| jq -r '.authenticated'
- name: Test CLI Installation should fail
id: cli-test
continue-on-error: true
run: cloudsmith --version
- name: Verify CLI installation failed
if: steps.cli-test.outcome == 'success'
run: |
echo "CLI installation should have failed but succeeded"
exit 1