Skip to content

Commit 498a076

Browse files
committed
WIP: mac workflows to be tested in odockal fork
Signed-off-by: Ondrej Dockal <[email protected]>
1 parent e39275d commit 498a076

File tree

3 files changed

+278
-0
lines changed

3 files changed

+278
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This example workflow represents an independent workflow that tests something, runs after E2E test Job is finished
2+
# and makes use of startJob machine's access information
3+
name: Dummy Mac Test Job
4+
5+
on:
6+
workflow_call:
7+
secrets:
8+
env_vars:
9+
required: true
10+
11+
jobs:
12+
dummy-mac-job:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
16+
steps:
17+
- name: Decode credentials as environment variables
18+
env:
19+
env_vars: ${{ secrets.env_vars }}
20+
run: |
21+
for i in $env_vars; do
22+
i=$(echo $i | sed 's/=.*//g')=$(echo ${i#*=} | base64 -di | base64 -di)
23+
echo ::add-mask::${i#*=}
24+
printf '%s\n' "$i" >> $GITHUB_ENV
25+
done
26+
- name: Validate credentials
27+
run: |
28+
# Secrets are now available as masked environment variable.
29+
echo $HOST_ID # or ${{ env.HOST_ID }}
30+
31+
- name: Run tests
32+
run: |
33+
echo "Testing like a devil"
34+
35+
- name: Archive artifacts
36+
run: |
37+
echo "archiving..."
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Idea of this Mac based workflows is as follows:
2+
# Main job (this one), controlls the schedulling of the associated jobs.
3+
# It also creates an initial request for a host machine on AWS and grants the access to the machine to the particular jobs.
4+
# Associated jobs has their own scheduller that must be agreed upon outside of this job.
5+
# Once the external job is started, it requires this job to get access to the secrets require to connect to the machine using qenvs project
6+
# At the end of the day, another schedulled trigger runs a clean up job that will destroy the instance and free up resources.
7+
8+
# Questions
9+
# 1. Should we rely on providing a concrete time frames to a various jobs/teams to make use of the machine?
10+
# 2. Jobs could be run in a sequence, one after another. Every job would need to have a timeout set so we can execute all in 24 hours
11+
# 3. How can we make use of an access information if the jobs are done and we still have a dedicated time on the machine?
12+
# 4. What teams to include? This sound like totally different project/repo
13+
14+
15+
# Solution of passing secrets is based on https://github.com/orgs/community/discussions/13082
16+
17+
name: Mac Workflow Scheduler
18+
19+
# env:
20+
# CRON_START: '1 10 * * 4' # “At 10:01 on Thursday.”
21+
# CRON_END: '10 10 * * 4' # “At 10:10 on Thursday.”
22+
23+
# on:
24+
# schedule:
25+
# - cron: '1 10 * * 4' # “At 10:01 on Thursday.”
26+
# - cron: '10 10 * * 4' # “At 10:10 on Thursday.”
27+
28+
on:
29+
workflow_dispatch:
30+
31+
jobs:
32+
createHostJob:
33+
runs-on: ubuntu-latest
34+
# if: ${{ github.event_name == 'schedule' && github.event.inputs.cron == ${{ env.CRON_START }} }}
35+
36+
outputs:
37+
host_id: ${{ steps.set_secret.outputs.host_id }}
38+
39+
steps:
40+
- name: Create a host instance on AWS
41+
run: |
42+
# Create host only - How to get host ID?
43+
# podman run -d --name mac-create --rm \
44+
# -v ${PWD}:/workspace:z \
45+
# -e AWS_ACCESS_KEY_ID=${{ AWS_ACCESS_KEY_ID }} \
46+
# -e AWS_SECRET_ACCESS_KEY='${{ AWS_SECRET_ACCESS_KEY }}' \
47+
# -e AWS_DEFAULT_REGION=us-east-1 \
48+
# quay.io/rhqp/qenvs:${{ matrix.qenvs-version }} aws \
49+
# mac create \
50+
# --host-only
51+
# --project-name mac-desktop \
52+
# --backed-url file:///workspace \
53+
# --conn-details-output /workspace \
54+
# # Check logs
55+
# podman logs -f mac-create
56+
# Simulate step that creates dedicatedHostID
57+
echo "asd123-asd11-44556" >> /workspace/dedicatedHostID
58+
# Read Host ID, encrypt it and pass it to the gha outputs
59+
echo "Host ID: $(cat /workspace/dedicatedHostID)"
60+
61+
- name: Output encoded secrets
62+
id: set_secret
63+
# env:
64+
# HOST: ${{ secrets.HOST }}
65+
# KEY: ${{ secrets.KEY }}
66+
run: |
67+
host_id=$(cat /workspace/dedicatedHostID | base64 -w0 | base64 -w0)
68+
echo "host_id is $host_id"
69+
echo "host_id=$host_id" >> $GITHUB_OUTPUT
70+
71+
podman-e2e:
72+
uses: ./.github/workflows/podman-e2e-mac.yaml
73+
needs: createHostJob
74+
secrets:
75+
env_vars: |
76+
HOST_ID=${{ needs.createHostJob.outputs.host_id }}
77+
78+
mac-template:
79+
uses: ./.github/workflows/mac-dummy-template.yaml
80+
needs: createHostJob
81+
secrets:
82+
env_vars: |
83+
HOST_ID=${{ needs.startJob.createHostJob.host_id }}
84+
85+
cleanUpJob:
86+
runs-on: ubuntu-latest
87+
needs: [createHostJob, podman-e2e, mac-template]
88+
env:
89+
env_vars: |
90+
HOST_ID: ${{ needs.createHostJob.outputs.host_id }}
91+
# if: ${{ github.event_name == 'schedule' && github.event.inputs.cron == ${{ env.CRON_END }} }}
92+
93+
# outputs:
94+
# host: ${{ steps.createHostJob.outputs.host }}
95+
96+
steps:
97+
- name: Running Clean up Action
98+
run: |
99+
echo "Final job is running with HOST_ID=${{ needs.createHostJob.outputs.HOST_ID }}"
100+
echo "Bye bye"
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# This example workflow represents an independent workflow that tests something, runs after E2E test Job is finished
2+
# and makes use of startJob machine's access information
3+
4+
name: Podman E2E with Podman installation on Mac OS
5+
6+
on:
7+
workflow_call:
8+
secrets:
9+
env_vars:
10+
required: true
11+
12+
jobs:
13+
podman-e2e:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
version: ['13','14']
19+
arch: ['m1', 'm2']
20+
qenvs-version: ['v0.6.1']
21+
22+
steps:
23+
- name: Decode credentials as environment variables
24+
env:
25+
env_vars: ${{ secrets.env_vars }}
26+
run: |
27+
for i in $env_vars; do
28+
i=$(echo $i | sed 's/=.*//g')=$(echo ${i#*=} | base64 -di | base64 -di)
29+
echo ::add-mask::${i#*=}
30+
printf '%s\n' "$i" >> $GITHUB_ENV
31+
done
32+
33+
- name: Validate credentials
34+
run: |
35+
# Secrets are now available as masked environment variable.
36+
echo $HOST_D # or ${{ env.HOST_ID }}
37+
38+
- name: Create instance on the host passing --host-id
39+
run: |
40+
# # Create instance with provided HOST_ID
41+
# podman run -d --name mac-create --rm \
42+
# -v ${PWD}:/workspace:z \
43+
# -e AWS_ACCESS_KEY_ID=${{ AWS_ACCESS_KEY_ID }} \
44+
# -e AWS_SECRET_ACCESS_KEY='${{ AWS_SECRET_ACCESS_KEY }}' \
45+
# -e AWS_DEFAULT_REGION=us-east-1 \
46+
# quay.io/rhqp/qenvs:${{ matrix.qenvs-version }} aws \
47+
# mac create \
48+
# --host-id ${{ env.HOST_ID }}
49+
# --project-name mac-desktop \
50+
# --backed-url file:///workspace \
51+
# --conn-details-output /workspace \
52+
# --version '${{ matrix.version }}' \
53+
# --arch '${{ matrix.arch }}'
54+
# # Check logs
55+
# podman logs -f mac-create
56+
echo "Passing ${{ env.HOST_ID }} info"
57+
58+
# - name: Check instance system info
59+
# run: |
60+
# ssh -i id_rsa \
61+
# -o StrictHostKeyChecking=no \
62+
# -o UserKnownHostsFile=/dev/null \
63+
# -o ServerAliveInterval=30 \
64+
# -o ServerAliveCountMax=1200 \
65+
# $(cat username)@$(cat host) "systeminfo"
66+
67+
# - name: Emulate X session
68+
# run: |
69+
# # use fake rdp to emulate an active x session
70+
# podman run -d --name x-session \
71+
# -e RDP_HOST=$(cat host) \
72+
# -e RDP_USER=$(cat username) \
73+
# -e RDP_PASSWORD=$(cat userpassword) \
74+
# quay.io/rhqp/frdp:v0.0.1
75+
# # Wait until the x session has been created
76+
# podman wait --condition running x-session
77+
# # Check logs for the x session
78+
# podman logs x-session
79+
80+
# - name: Run podman desktop e2e
81+
# run: |
82+
# # Get latest built
83+
# tag=$(curl --silent https://api.github.com/repos/containers/podman-desktop/releases | jq -r 'map(select(.prerelease)) | first | .tag_name')
84+
# # Run e2e tests
85+
# podman run --rm -d --name pd-e2e-mac \
86+
# -e TARGET_HOST=$(cat host) \
87+
# -e TARGET_HOST_USERNAME=$(cat username) \
88+
# -e TARGET_HOST_KEY_PATH=/data/id_rsa \
89+
# -e TARGET_FOLDER=pd-e2e \
90+
# -e TARGET_RESULTS=podman-desktop-e2e-results-${tag}.xml \
91+
# -e OUTPUT_FOLDER=/data \
92+
# -e DEBUG=true \
93+
# -v $PWD:/data:z \
94+
# quay.io/rhqp/podman-desktop-e2e:v1.1.0-windows-amd64 \
95+
# pd-e2e/run.ps1 \
96+
# -wslInstallFix 'false' \
97+
# -targetFolder pd-e2e \
98+
# -pdUrl "https://github.com/containers/podman-desktop/releases/download/${tag}/podman-desktop-${tag:1}.exe" \
99+
# -junitResultsFilename podman-desktop-e2e-results-${tag}.xml
100+
# # Check logs
101+
# podman logs -f pd-e2e-mac
102+
103+
- name: Destroy instance
104+
if: always()
105+
run: |
106+
# # Destroy instance
107+
# podman run -d --name mac-destroy --rm \
108+
# -v ${PWD}:/workspace:z \
109+
# -e AWS_ACCESS_KEY_ID=${{ AWS_ACCESS_KEY_ID }} \
110+
# -e AWS_SECRET_ACCESS_KEY='${{ AWS_SECRET_ACCESS_KEY }}' \
111+
# -e AWS_DEFAULT_REGION=us-east-1 \
112+
# quay.io/rhqp/qenvs:${{ matrix.qenvs-version }} aws \
113+
# mac destroy \
114+
# --host-id ${{ env.HOST_ID }}
115+
# --project-name mac-desktop \
116+
# --backed-url 'file:///workspace'
117+
# # Check logs
118+
# podman logs -f mac-destroy
119+
echo "Destroying instance with ${{ env.HOST_ID }}"
120+
121+
# - name: Publish Test Report
122+
# uses: mikepenz/action-junit-report@v4
123+
# if: always() # always run even if the previous step fails
124+
# with:
125+
# fail_on_failure: true
126+
# include_passed: true
127+
# detailed_summary: true
128+
# require_tests: true
129+
# report_paths: '**/*results*.xml'
130+
131+
# - name: Upload e2e test artifacts
132+
# uses: actions/upload-artifact@v4
133+
# if: always()
134+
# with:
135+
# name: E2E-results-mac-${{ matrix.version }}${{ matrix.arch }}
136+
# path: |
137+
# podman-e2e-results-*.xml
138+
# podman-desktop-e2e-results-*.xml
139+
140+
141+

0 commit comments

Comments
 (0)