Skip to content

Commit fe6ecbb

Browse files
authored
Merge pull request #18 from sustainable-computing-io/integrateWithKeplerAction
Integrate with kepler action
2 parents dfa5bbb + 170ec9a commit fe6ecbb

File tree

3 files changed

+158
-2
lines changed

3 files changed

+158
-2
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ jobs:
4747

4848
unitpreOS:
4949
strategy:
50+
fail-fast: false
5051
matrix:
5152
# us-east-2
5253
# Ubuntu 20.04 AMI is ami-0e4d0bb9670ea8db0
5354
# ubuntu 22.04 AMI is ami-05fb0b8c1424f266b
5455
# RHEL 9 AMI is ami-078cbc4c2d057c244
55-
AMI_ID: [ami-0e4d0bb9670ea8db0,ami-05fb0b8c1424f266b,ami-078cbc4c2d057c244]
56+
AMI_ID: [ami-0e4d0bb9670ea8db0,ami-078cbc4c2d057c244]
5657
uses: ./.github/workflows/ci_unit.yml
5758
secrets:
5859
AWS_REGION: ${{ secrets.AWS_REGION }}
@@ -61,4 +62,23 @@ jobs:
6162
GH_SELF_HOSTED_RUNNER_TOKEN: ${{ secrets.GH_SELF_HOSTED_RUNNER_TOKEN }}
6263
AWS_SECURITY_GROUP_ID: ${{ secrets.AWS_SECURITY_GROUP_ID }}
6364
AMI_ID: ${{matrix.AMI_ID}}
65+
66+
integration:
67+
needs: [unitpreOS]
68+
strategy:
69+
fail-fast: false
70+
matrix:
71+
# us-east-2
72+
# Ubuntu 20.04 AMI is ami-0e4d0bb9670ea8db0
73+
# ubuntu 22.04 AMI is ami-05fb0b8c1424f266b
74+
# RHEL 9 AMI is ami-078cbc4c2d057c244
75+
AMI_ID: [ami-05fb0b8c1424f266b]
76+
uses: ./.github/workflows/ci_integration.yml
77+
secrets:
78+
AWS_REGION: ${{ secrets.AWS_REGION }}
79+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
80+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
81+
GH_SELF_HOSTED_RUNNER_TOKEN: ${{ secrets.GH_SELF_HOSTED_RUNNER_TOKEN }}
82+
AWS_SECURITY_GROUP_ID: ${{ secrets.AWS_SECURITY_GROUP_ID }}
83+
AMI_ID: ${{matrix.AMI_ID}}
6484

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# shellcheck disable=SC1000-SC9999
2+
name: Continuous Integration
3+
4+
on:
5+
workflow_call:
6+
secrets:
7+
AWS_REGION:
8+
required: true
9+
AWS_ACCESS_KEY_ID:
10+
required: true
11+
AWS_SECRET_ACCESS_KEY:
12+
required: true
13+
AWS_SECURITY_GROUP_ID:
14+
required: true
15+
AMI_ID:
16+
required: true
17+
GH_SELF_HOSTED_RUNNER_TOKEN:
18+
required: true
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
setup-runner:
25+
name: GitHub Actions Test create instance
26+
runs-on: ubuntu-latest
27+
outputs:
28+
instance_id: ${{ steps.create-runner.outputs.instance_id }}
29+
runner_name: ${{ steps.create-runner.outputs.runner_name }}
30+
steps:
31+
- name: Checkout
32+
id: checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Test Local Action
36+
id: create-runner
37+
uses: ./
38+
with:
39+
action: "create"
40+
aws_region: ${{ secrets.AWS_REGION }}
41+
github_token: ${{ secrets.GH_SELF_HOSTED_RUNNER_TOKEN }}
42+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
43+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
44+
security_group_id: ${{ secrets.AWS_SECURITY_GROUP_ID }}
45+
github_repo: ${{ github.repository }}
46+
ami_id: ${{ secrets.AMI_ID }}
47+
instance_type: "i3.metal"
48+
create_s3_bucket: "false"
49+
spot_instance_only: "true"
50+
51+
- name: Print Output
52+
id: output
53+
run: |
54+
echo "instance_id ${{ steps.create-runner.outputs.instance_id }}"
55+
echo "instance_ip ${{ steps.create-runner.outputs.instance_ip }}"
56+
echo "runner_name ${{ steps.create-runner.outputs.runner_name }}"
57+
echo "bucket_name ${{ steps.create-runner.outputs.bucket_name }}"
58+
59+
test-runner:
60+
needs: setup-runner
61+
runs-on: [self-hosted, linux, x64]
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v4
65+
66+
- name: Install Docker
67+
id: docker
68+
run: |
69+
# Add Docker's official GPG key:
70+
apt-get update -y
71+
apt-get install ca-certificates curl gnupg -y
72+
install -m 0755 -d /etc/apt/keyrings
73+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
74+
chmod a+r /etc/apt/keyrings/docker.gpg
75+
# Add the repository to Apt sources:
76+
echo \
77+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
78+
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
79+
tee /etc/apt/sources.list.d/docker.list > /dev/null
80+
apt-get update -y
81+
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
82+
docker info
83+
84+
- name: install make and tooling for libbpf
85+
id: dependency
86+
run: |
87+
apt-get install -y binutils-dev build-essential
88+
apt-get install -y pkg-config
89+
env
90+
91+
- name: use Kepler action to deploy cluster
92+
uses: sustainable-computing-io/kepler-action@main
93+
with:
94+
ebpfprovider: libbpf
95+
cluster_provider: kind
96+
prometheus_enable: true
97+
tekton_enable: true
98+
99+
- name: Run Tests
100+
run: |
101+
export INSTANCE_ID="${{ needs.setup-runner.outputs.instance_id }}"
102+
echo "Running tests on self-hosted runner with instance ${INSTANCE_ID}"
103+
uname -a # or any other command
104+
cat /etc/os-release
105+
cat /proc/cpuinfo
106+
kind get kubeconfig --name=kind > /tmp/kubeconfig
107+
kubectl get po --all-namespaces --kubeconfig=/tmp/kubeconfig
108+
109+
destroy-runner:
110+
if: always()
111+
name: GitHub Actions Test destroy instance
112+
needs: [setup-runner, test-runner]
113+
runs-on: ubuntu-latest
114+
steps:
115+
- name: Checkout
116+
id: checkout
117+
uses: actions/checkout@v4
118+
119+
- name: unregister runner
120+
id: unregister
121+
uses: ./
122+
with:
123+
action: "unregister"
124+
runner_name: ${{ needs.setup-runner.outputs.runner_name }}
125+
github_token: ${{ secrets.GH_SELF_HOSTED_RUNNER_TOKEN }}
126+
github_repo: ${{ github.repository }}
127+
128+
- name: terminate instance
129+
id: terminate
130+
uses: ./
131+
with:
132+
action: "terminate"
133+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
134+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
135+
instance_id: ${{ needs.setup-runner.outputs.instance_id }}
136+

.github/workflows/ci_unit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
echo "Running tests on self-hosted runner with instance ${INSTANCE_ID}"
7070
uname -a # or any other command
7171
cat /etc/os-release
72-
cat /proc/cpuinfo
72+
cat /proc/cpuinfo
7373
7474
destroy-runner:
7575
if: always()

0 commit comments

Comments
 (0)