Skip to content

Commit 3ce5b43

Browse files
committed
Mac Workflows initial concept with podman-e2e-mac workflow, scheduler and template
Signed-off-by: Ondrej Dockal <[email protected]>
1 parent e39275d commit 3ce5b43

File tree

3 files changed

+318
-0
lines changed

3 files changed

+318
-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 dummy workflow serves as a template for
2+
# other possible workflows getting information for creating a Mac host from its parent scheduler job
3+
name: Dummy Mac Template 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: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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 on AWS
41+
# run: |
42+
# Create host only - How to get host ID?
43+
# podman run -d --name mac-host-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-host-create
56+
# Simulate step that creates dedicatedHostID
57+
run: |
58+
# requires sudo! mkdir /workspace
59+
mkdir workspace
60+
echo "asd123-asd11-44556" >> $GITHUB_WORKSPACE/workspace/dedicatedHostID
61+
# Read Host ID, encrypt it and pass it to the gha outputs
62+
echo "Host ID: $(cat $GITHUB_WORKSPACE/workspace/dedicatedHostID)"
63+
64+
- name: Output encoded secrets
65+
id: set_secret
66+
run: |
67+
host_id=$(cat $GITHUB_WORKSPACE/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.createHostJob.outputs.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"
101+
102+
- name: Destroy instance
103+
if: always()
104+
# run: |
105+
# # Destroy instance
106+
# podman run -d --name mac-host-destroy --rm \
107+
# -v ${PWD}:/workspace:z \
108+
# -e AWS_ACCESS_KEY_ID=${{ AWS_ACCESS_KEY_ID }} \
109+
# -e AWS_SECRET_ACCESS_KEY='${{ AWS_SECRET_ACCESS_KEY }}' \
110+
# -e AWS_DEFAULT_REGION=us-east-1 \
111+
# quay.io/rhqp/qenvs:${{ matrix.qenvs-version }} aws \
112+
# mac destroy \
113+
# --host-only
114+
# --project-name mac-desktop \
115+
# --backed-url 'file:///workspace'
116+
# # Check logs
117+
# podman logs -f mac-host-destroy
118+
run: |
119+
echo "Destroying the AWS host using --host-only"
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
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+
workflow_dispatch:
12+
inputs:
13+
host_id:
14+
description: 'AWS Host ID'
15+
type: string
16+
required: false
17+
18+
jobs:
19+
podman-e2e:
20+
runs-on: ubuntu-latest
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
# version: ['13','14']
25+
version: ['14']
26+
# arch: ['m1', 'm2']
27+
arch: ['m1']
28+
qenvs-version: ['v0.6.1']
29+
30+
steps:
31+
- name: Decode credentials as environment variables
32+
# Runs only is the trigger event is a workflow call - run by mac-scheduler
33+
if: github.event_name == 'workflow_call'
34+
env:
35+
env_vars: ${{ secrets.env_vars }}
36+
run: |
37+
echo "Getting HOST_ID from parent workflow"
38+
for i in $env_vars; do
39+
i=$(echo $i | sed 's/=.*//g')=$(echo ${i#*=} | base64 -di | base64 -di)
40+
echo ::add-mask::${i#*=}
41+
printf '%s\n' "$i" >> $GITHUB_ENV
42+
done
43+
44+
- name: Set host id into environment variables
45+
# Runs only is the trigger event is a workflow dispatch - run manually
46+
if: github.event_name == 'workflow_dispatch'
47+
env:
48+
HOST_ID: ${{ github.event.inputs.host_id }}
49+
run: |
50+
echo "Setting HOST_ID from Workflow input: ${{ env.HOST_ID }}"
51+
52+
- name: Validate Host ID
53+
run: |
54+
# Secrets are now available as masked environment variable.
55+
echo $HOST_D # or ${{ env.HOST_ID }}
56+
57+
- name: Create instance on the host passing --host-id
58+
# run: |
59+
# # Create instance with provided HOST_ID
60+
# podman run -d --name mac-create --rm \
61+
# -v ${PWD}:/workspace:z \
62+
# -e AWS_ACCESS_KEY_ID=${{ AWS_ACCESS_KEY_ID }} \
63+
# -e AWS_SECRET_ACCESS_KEY='${{ AWS_SECRET_ACCESS_KEY }}' \
64+
# -e AWS_DEFAULT_REGION=us-east-1 \
65+
# quay.io/rhqp/qenvs:${{ matrix.qenvs-version }} aws \
66+
# mac create \
67+
# --host-id ${{ env.HOST_ID }}
68+
# --project-name mac-desktop \
69+
# --backed-url file:///workspace \
70+
# --conn-details-output /workspace \
71+
# --version '${{ matrix.version }}' \
72+
# --arch '${{ matrix.arch }}'
73+
# # Check logs
74+
# podman logs -f mac-create
75+
run: |
76+
echo "Passing ${{ env.HOST_ID }} info"
77+
78+
# - name: Check instance system info
79+
# run: |
80+
# ssh -i id_rsa \
81+
# -o StrictHostKeyChecking=no \
82+
# -o UserKnownHostsFile=/dev/null \
83+
# -o ServerAliveInterval=30 \
84+
# -o ServerAliveCountMax=1200 \
85+
# $(cat username)@$(cat host) "systeminfo"
86+
87+
# - name: Emulate X session
88+
# run: |
89+
# # use fake rdp to emulate an active x session
90+
# podman run -d --name x-session \
91+
# -e RDP_HOST=$(cat host) \
92+
# -e RDP_USER=$(cat username) \
93+
# -e RDP_PASSWORD=$(cat userpassword) \
94+
# quay.io/rhqp/frdp:v0.0.1
95+
# # Wait until the x session has been created
96+
# podman wait --condition running x-session
97+
# # Check logs for the x session
98+
# podman logs x-session
99+
100+
# - name: Run podman desktop e2e
101+
# run: |
102+
# # Get latest built
103+
# tag=$(curl --silent https://api.github.com/repos/containers/podman-desktop/releases | jq -r 'map(select(.prerelease)) | first | .tag_name')
104+
# # Run e2e tests
105+
# podman run --rm -d --name pd-e2e-mac \
106+
# -e TARGET_HOST=$(cat host) \
107+
# -e TARGET_HOST_USERNAME=$(cat username) \
108+
# -e TARGET_HOST_KEY_PATH=/data/id_rsa \
109+
# -e TARGET_FOLDER=pd-e2e \
110+
# -e TARGET_RESULTS=podman-desktop-e2e-results-${tag}.xml \
111+
# -e OUTPUT_FOLDER=/data \
112+
# -e DEBUG=true \
113+
# -v $PWD:/data:z \
114+
# quay.io/rhqp/podman-desktop-e2e:v1.1.0-windows-amd64 \
115+
# pd-e2e/run.ps1 \
116+
# -wslInstallFix 'false' \
117+
# -targetFolder pd-e2e \
118+
# -pdUrl "https://github.com/containers/podman-desktop/releases/download/${tag}/podman-desktop-${tag:1}.exe" \
119+
# -junitResultsFilename podman-desktop-e2e-results-${tag}.xml
120+
# # Check logs
121+
# podman logs -f pd-e2e-mac
122+
123+
- name: Destroy instance
124+
if: always()
125+
# run: |
126+
# # # Destroy instance
127+
# # podman run -d --name mac-destroy --rm \
128+
# # -v ${PWD}:/workspace:z \
129+
# # -e AWS_ACCESS_KEY_ID=${{ AWS_ACCESS_KEY_ID }} \
130+
# # -e AWS_SECRET_ACCESS_KEY='${{ AWS_SECRET_ACCESS_KEY }}' \
131+
# # -e AWS_DEFAULT_REGION=us-east-1 \
132+
# # quay.io/rhqp/qenvs:${{ matrix.qenvs-version }} aws \
133+
# # mac destroy \
134+
# # --host-id ${{ env.HOST_ID }}
135+
# # --project-name mac-desktop \
136+
# # --backed-url 'file:///workspace'
137+
# # # Check logs
138+
# # podman logs -f mac-destroy
139+
run: |
140+
echo "Destroying instance with ${{ env.HOST_ID }}"
141+
142+
# - name: Publish Test Report
143+
# uses: mikepenz/action-junit-report@v4
144+
# if: always() # always run even if the previous step fails
145+
# with:
146+
# fail_on_failure: true
147+
# include_passed: true
148+
# detailed_summary: true
149+
# require_tests: true
150+
# report_paths: '**/*results*.xml'
151+
152+
# - name: Upload e2e test artifacts
153+
# uses: actions/upload-artifact@v4
154+
# if: always()
155+
# with:
156+
# name: E2E-results-mac-${{ matrix.version }}${{ matrix.arch }}
157+
# path: |
158+
# podman-e2e-results-*.xml
159+
# podman-desktop-e2e-results-*.xml
160+
161+
162+

0 commit comments

Comments
 (0)