Skip to content

Commit 8c5ef21

Browse files
committed
CI: fix build and processing results
The expectation was that we'd need an ssh key with a passphrase. The github way to leverage an ssh-agent is through webfactory [0 and they insist that since the key is uploaded to github that suffices. The passphrase is not supported so remove it. The local user ssh-agent is not used or leveraged by github actions, and so we in order to automatically push onto kdevops-results-archive you will need to leverage github repository secrets for the key, once that is installed you will also need to add the public key to the kdevops-repository-results as a "deploy" key. - fstests.yml: - use webfactory/ssh-agent v0.9.0 - simplify the way we look for zip files on artifacts, just use a glob - fix the fstests.yml kdevops path for the zip file - kdevops_archive: - reduce scope and use github repo private secrets - add debug info about archive files Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 02fcda1 commit 8c5ef21

File tree

3 files changed

+30
-147
lines changed

3 files changed

+30
-147
lines changed

.github/workflows/fstests.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
- name: Checkout repository
1818
uses: actions/checkout@v4
1919

20+
- name: Set kdevops path
21+
run: echo "KDEVOPS_PATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
22+
2023
- name: Configure git
2124
run: |
2225
git config --global --add safe.directory '*'
@@ -51,25 +54,23 @@ jobs:
5154
cd kdevops
5255
make journal-dump
5356
57+
- name: Start SSH Agent
58+
if: always() # Ensure this step runs even if previous steps failed
59+
uses: webfactory/[email protected]
60+
with:
61+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
62+
5463
- name: Build our kdevops archive results
5564
if: always() # This ensures the step runs even if previous steps failed
5665
run: |
57-
cd kdevops
5866
make ci-archive
5967
60-
- name: Find and kdevops results zip file
61-
if: always() # This ensures the step runs even if previous steps failed
62-
run: |
63-
ZIP_FILE=$(find kdevops/archive -name "*.zip" -type f | head -n 1)
64-
echo "Found zip file: $ZIP_FILE"
65-
echo "KDEVOPS_ARTIFACT_PATH=$ZIP_FILE" >> $GITHUB_ENV
66-
6768
- name: Upload our kdevops results archive
6869
if: always() # This ensures the step runs even if previous steps failed
6970
uses: actions/upload-artifact@v4
7071
with:
7172
name: kdevops-ci-results
72-
path: ${{ env.KDEVOPS_ARTIFACT_PATH }}
73+
path: ${{ env.KDEVOPS_PATH }}/archive/*.zip
7374

7475
# Ensure make destroy always runs, even on failure
7576
- name: Run kdevops make destroy

playbooks/roles/kdevops_archive/defaults/main.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ kdevops_results_archive_dir: "{{ topdir_path }}/../{{ kdevops_results_name }}"
1111
kdevops_archive_mirror_present: false
1212
kdevops_archive_host: "{{ kdevops_results_repo_path.split(':')[0] }}"
1313
kdevops_archive: "/mirror/{{ kdevops_results_name }}.git"
14-
kdevops_archive_key_loaded: False
15-
kdevops_archive_key_name: "kdevops_archive"
16-
kdevops_archive_identity_file: "/home/gh/.ssh/{{ kdevops_archive }}"
17-
kdevops_archive_key_detected: False
18-
kdevops_archive_key_fingerprint: ""
19-
kdevops_archive_key_has_passphrase: False
2014
kdevops_archive_demo: False
2115
bootlinux_tree_set_by_cli: False
2216
kdevops_archive_base: "selftests/gh/linux-modules-kpd/20241021"

playbooks/roles/kdevops_archive/tasks/main.yml

Lines changed: 20 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -112,154 +112,42 @@
112112
chdir: "{{ topdir_path }}"
113113
when: ci_results.stdout_lines | length > 0
114114

115-
- name: Create our archive/ tar.xz for our test results
115+
- name: Create our archive/ xz file for kdevops-results-archive
116116
archive:
117117
path: "{{ kdevops_results_local }}"
118118
dest: "{{ kdevops_results }}/{{ target_linux_ref }}.xz"
119119
format: xz
120120
remove: no
121121

122-
- name: Create the same zip archive as well
122+
- name: Create the same archive/ zip file for web CI artifacts
123123
archive:
124124
path: "{{ kdevops_results_local }}"
125125
dest: "{{ kdevops_results }}/{{ target_linux_ref }}.zip"
126126
format: zip
127127
remove: no
128128

129-
- name: Get SSH configuration for the kdevops archive repo
130-
ansible.builtin.command: ssh -G {{ kdevops_results_repo_url_user }}@{{ kdevops_results_repo_path }}
131-
register: ssh_archive_config_repo
132-
changed_when: false
133-
134-
- name: Extract kdevops archive repo IdentityFile
135-
vars:
136-
identity_file_lines: "{{ ssh_archive_config_repo.stdout_lines | select('match', '^identityfile ') }}"
137-
identity_file_raw: "{{ identity_file_lines | first | regex_replace('^identityfile (.*)$', '\\1') }}"
138-
ansible.builtin.set_fact:
139-
kdevops_archive_identity_file: "{{ identity_file_raw | regex_replace('^~', lookup('env', 'HOME')) }}"
140-
141-
- name: Check if the key used for the kdevops archive repo is installed
142-
ansible.builtin.set_fact:
143-
kdevops_archive_key_detected: "{{ kdevops_archive_key_name in (kdevops_archive_identity_file | basename) }}"
144-
145-
- name: Inform user of how to set up the kdevops archive repo key
146-
ansible.builtin.debug:
147-
msg: |
148-
ssh key archive test for {{ kdevops_results_repo_url }}:
149-
We ran:
150-
151-
ssh -G {{ kdevops_results_repo_url_user }}@{{ kdevops_results_repo_path }} | grep identityfile
152-
153-
Missing key name: '{{ kdevops_archive_key_name }}'
154-
Current IdentityFile:
155-
{{ kdevops_archive_identity_file }}
156-
157-
To set up automatic kdevops repo archiving install something like
158-
the following key for host {{ kdevops_archive_host }}:
159-
160-
Host {{ kdevops_results_repo_path }}
161-
User {{ kdevops_results_repo_url_user }}
162-
Hostname {{ kdevops_archive_host }}
163-
IdentityFile {{ lookup('env', 'HOME') }}/.ssh/{{ kdevops_archive_key_name }}
164-
165-
166-
Create the key first with something like:
167-
168-
ssh-keygen -t ed25519 -C "{{ kdevops_results_repo_url_user}}@{{ kdevops_results_repo_path }}" -f {{ lookup('env', 'HOME') }}/.ssh/{{ kdevops_archive_key_name }}
169-
170-
Then install it as deploy key for {{ kdevops_results_repo_path}}:
171-
172-
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/managing-deploy-keys#deploy-keys
173-
174-
And then add the above to your {{ lookup('env', 'HOME') }}/.ssh/config
175-
176-
when:
177-
- 'not kdevops_archive_key_detected|bool'
178-
- 'bootlinux_tree_set_by_cli|bool'
179-
180-
- name: Gracefully end if key is not found for automatic kdevops archiving
181-
meta: end_play
182-
when:
183-
- not kdevops_archive_key_detected
184-
185-
- name: Check if the detected kdevops archive repo key exists
186-
ansible.builtin.stat:
187-
path: "{{ kdevops_archive_identity_file }}"
188-
register: ssh_key_file_lookup
189-
190-
- name: Inform user of configured but not created key
191-
ansible.builtin.debug:
192-
msg: |
193-
Key to be used missing: {{ kdevops_archive_identity_file }}
194-
Create the key with something like:
195-
ssh-keygen -t ed25519 -C "{{ kdevops_results_repo_url_user}}@{{ kdevops_results_repo_path }}" -f {{ lookup('env', 'HOME') }}/.ssh/{{ kdevops_archive_key_name }}
196-
when:
197-
- not ssh_key_file_lookup.stat.exists
198-
199-
- name: Gracefully end if key does not exist
200-
meta: end_play
201-
when:
202-
- not ssh_key_file_lookup.stat.exists
129+
- name: Find archive files to verify
130+
find:
131+
paths: "{{ kdevops_results }}"
132+
patterns:
133+
- "*.zip"
134+
- "*.xz"
135+
register: archive_files
203136

204-
- name: Check if kdevops results archive ssh key has a passphrase
205-
ansible.builtin.command:
206-
cmd: "ssh-keygen -y -f {{ kdevops_archive_identity_file }}"
207-
register: ssh_key_check
208-
ignore_errors: yes
137+
- name: Get archive file stat
138+
stat:
139+
path: "{{ item.path }}"
140+
register: archive_stats
141+
loop: "{{ archive_files.files }}"
209142
changed_when: false
210-
failed_when: false
211143
no_log: true
212144

213-
- name: Set fact about SSH key passphrase status
214-
ansible.builtin.set_fact:
215-
kdevops_archive_key_has_passphrase: "{{ ssh_key_check.rc != 0 }}"
216-
217-
- name: Inform user if key did not have a passphrase
218-
ansible.builtin.debug:
219-
msg: |
220-
ssh key archive {{ kdevops_archive_identity_file }} for {{ kdevops_results_repo_url }}
221-
does not have a passphrase. This not secure and not allowed. Giving up.
222-
when:
223-
- 'not kdevops_archive_key_has_passphrase|bool'
224-
225-
- name: End if key did not have passphrase set up
226-
meta: end_play
227-
when:
228-
- 'not kdevops_archive_key_has_passphrase|bool'
229-
230-
- name: Gracefully end if the user did not set up a kdevops archive repo key
231-
meta: end_play
232-
when: not kdevops_archive_key_detected
233-
234-
- name: Get fingerprint of the identity file for {{ kdevops_archive_key_name }}
235-
ansible.builtin.command: ssh-keygen -lf "{{ kdevops_archive_identity_file }}"
236-
register: kdevops_archive_fingerprint_output
237-
changed_when: false
238-
when:
239-
- 'kdevops_archive_key_detected|bool'
240-
241-
- name: Extract the {{ kdevops_archive_key_name }} fingerprint
242-
ansible.builtin.set_fact:
243-
kdevops_archive_key_fingerprint: "{{ kdevops_archive_fingerprint_output.stdout.split()[1] }}"
244-
when:
245-
- 'kdevops_archive_key_detected|bool'
246-
247-
- name: List keys in ssh-agent
248-
ansible.builtin.command: ssh-add -l
249-
register: kdevops_archive_ssh_add_list
250-
changed_when: false
251-
when:
252-
- 'kdevops_archive_key_detected|bool'
253-
254-
- name: Check if key is loaded in ssh-agent
255-
ansible.builtin.set_fact:
256-
kdevops_archive_key_loaded: "{{ kdevops_archive_key_fingerprint in kdevops_archive_ssh_add_list.stdout }}"
257-
258-
- name: Inform when we are achiving
259-
ansible.builtin.debug:
260-
msg: "Achievement unlocked: kdevops archive key set up, automatic kdevops archiving enabled."
261-
when:
262-
- 'kdevops_archive_key_loaded|bool'
145+
- name: Display archive file information
146+
debug:
147+
msg: "{{ item.stat.path }} ({{ (item.stat.size / 1024 / 1024) | round(2) }}MB)"
148+
loop: "{{ archive_stats.results }}"
149+
loop_control:
150+
label: "{{ item.stat.path | basename }}"
263151

264152
- name: Check if kdevops-results-archive directory exists
265153
stat:

0 commit comments

Comments
 (0)