Skip to content

Commit

Permalink
Fix CI (#389)
Browse files Browse the repository at this point in the history
did all the things to make it work
  • Loading branch information
timothystewart6 committed Jan 25, 2024
1 parent edf0c9e commit e2e9881
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 146 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: "Cache"
on:
workflow_call:
jobs:
molecule:
name: cache
runs-on: self-hosted
env:
PYTHON_VERSION: "3.11"

steps:
- name: Check out the codebase
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v3 2.5.0
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@75f3110429a8c05be0e1bf360334e4cced2b63fa # 2.3.3
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip' # caching pip dependencies

- name: Cache Vagrant boxes
id: cache-vagrant
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # 4.0
with:
lookup-only: true #if it exists, we don't need to restore and can skip the next step
path: |
~/.vagrant.d/boxes
key: vagrant-boxes-${{ hashFiles('**/molecule.yml') }}
restore-keys: |
vagrant-boxes
- name: Download Vagrant boxes for all scenarios
# To save some cache space, all scenarios share the same cache key.
# On the other hand, this means that the cache contents should be
# the same across all scenarios. This step ensures that.
if: steps.cache-vagrant.outputs.cache-hit != 'true' # only run if false since this is just a cache step
run: |
./.github/download-boxes.sh
vagrant box list
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ on:
paths-ignore:
- '**/README.md'
jobs:
pre:
uses: ./.github/workflows/cache.yml
lint:
uses: ./.github/workflows/lint.yml
needs: [pre]
test:
uses: ./.github/workflows/test.yml
needs: [lint]
needs: [pre, lint]
24 changes: 5 additions & 19 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
jobs:
pre-commit-ci:
name: Pre-Commit
runs-on: ubuntu-latest
runs-on: self-hosted
env:
PYTHON_VERSION: "3.11"

Expand All @@ -21,21 +21,11 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip' # caching pip dependencies

- name: Cache pip
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # 3.0.11
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('./requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache Ansible
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # 3.0.11
- name: Restore Ansible cache
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # 4.0
with:
path: ~/.ansible/collections
key: ${{ runner.os }}-ansible-${{ hashFiles('collections/requirements.txt') }}
restore-keys: |
${{ runner.os }}-ansible-
key: ansible-${{ hashFiles('collections/requirements.yml') }}

- name: Install dependencies
run: |
Expand All @@ -47,16 +37,12 @@ jobs:
python3 -m pip install -r requirements.txt
echo "::endgroup::"
echo "::group::Install Ansible role requirements from collections/requirements.yml"
ansible-galaxy install -r collections/requirements.yml
echo "::endgroup::"
- name: Run pre-commit
uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507 # 3.0.0

ensure-pinned-actions:
name: Ensure SHA Pinned Actions
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v3 2.5.0
Expand Down
34 changes: 9 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
jobs:
molecule:
name: Molecule
runs-on: macos-12
runs-on: self-hosted
strategy:
matrix:
scenario:
Expand All @@ -30,35 +30,19 @@ jobs:
* fdad:bad:ba55::/64
EOF
- name: Cache pip
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # 3.0.11
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('./requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache Vagrant boxes
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # 3.0.11
with:
path: |
~/.vagrant.d/boxes
key: vagrant-boxes-${{ hashFiles('**/molecule.yml') }}
restore-keys: |
vagrant-boxes
- name: Download Vagrant boxes for all scenarios
# To save some cache space, all scenarios share the same cache key.
# On the other hand, this means that the cache contents should be
# the same across all scenarios. This step ensures that.
run: ./.github/download-boxes.sh

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@75f3110429a8c05be0e1bf360334e4cced2b63fa # 2.3.3
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip' # caching pip dependencies

- name: Restore vagrant Boxes cache
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # 4.0
with:
path: ~/.vagrant.d/boxes
key: vagrant-boxes-${{ hashFiles('**/molecule.yml') }}
fail-on-cache-miss: true

- name: Install dependencies
run: |
echo "::group::Upgrade pip"
Expand All @@ -75,7 +59,7 @@ jobs:
env:
ANSIBLE_K3S_LOG_DIR: ${{ runner.temp }}/logs/k3s-ansible/${{ matrix.scenario }}
ANSIBLE_SSH_RETRIES: 4
ANSIBLE_TIMEOUT: 60
ANSIBLE_TIMEOUT: 120
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1

Expand Down
13 changes: 7 additions & 6 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ platforms:

- name: control1
box: generic/ubuntu2204
memory: 2048
memory: 4096
cpus: 2
groups:
- k3s_cluster
Expand All @@ -23,7 +23,7 @@ platforms:

- name: control2
box: generic/debian11
memory: 2048
memory: 4096
cpus: 2
groups:
- k3s_cluster
Expand All @@ -34,7 +34,7 @@ platforms:

- name: control3
box: generic/rocky9
memory: 2048
memory: 4096
cpus: 2
groups:
- k3s_cluster
Expand All @@ -45,7 +45,7 @@ platforms:

- name: node1
box: generic/ubuntu2204
memory: 2048
memory: 4096
cpus: 2
groups:
- k3s_cluster
Expand All @@ -61,7 +61,7 @@ platforms:

- name: node2
box: generic/rocky9
memory: 2048
memory: 4096
cpus: 2
groups:
- k3s_cluster
Expand All @@ -72,6 +72,8 @@ platforms:

provisioner:
name: ansible
env:
ANSIBLE_VERBOSITY: 1
playbooks:
converge: ../resources/converge.yml
side_effect: ../resources/reset.yml
Expand All @@ -82,7 +84,6 @@ provisioner:
scenario:
test_sequence:
- dependency
- lint
- cleanup
- destroy
- syntax
Expand Down
9 changes: 5 additions & 4 deletions molecule/ipv6/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ driver:
platforms:
- name: control1
box: generic/ubuntu2204
memory: 2048
memory: 4096
cpus: 2
groups:
- k3s_cluster
Expand All @@ -22,7 +22,7 @@ platforms:

- name: control2
box: generic/ubuntu2204
memory: 2048
memory: 4096
cpus: 2
groups:
- k3s_cluster
Expand All @@ -38,7 +38,7 @@ platforms:

- name: node1
box: generic/ubuntu2204
memory: 2048
memory: 4096
cpus: 2
groups:
- k3s_cluster
Expand All @@ -53,6 +53,8 @@ platforms:
ssh.password: "vagrant"
provisioner:
name: ansible
env:
ANSIBLE_VERBOSITY: 1
playbooks:
converge: ../resources/converge.yml
side_effect: ../resources/reset.yml
Expand All @@ -63,7 +65,6 @@ provisioner:
scenario:
test_sequence:
- dependency
- lint
- cleanup
- destroy
- syntax
Expand Down
7 changes: 4 additions & 3 deletions molecule/single_node/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ driver:
platforms:
- name: control1
box: generic/ubuntu2204
memory: 4096
cpus: 4
memory: 8192
cpus: 8
config_options:
# We currently can not use public-key based authentication on Ubuntu 22.04,
# see: https://github.com/chef/bento/issues/1405
Expand All @@ -21,6 +21,8 @@ platforms:
ip: 192.168.30.50
provisioner:
name: ansible
env:
ANSIBLE_VERBOSITY: 1
playbooks:
converge: ../resources/converge.yml
side_effect: ../resources/reset.yml
Expand All @@ -31,7 +33,6 @@ provisioner:
scenario:
test_sequence:
- dependency
- lint
- cleanup
- destroy
- syntax
Expand Down
18 changes: 9 additions & 9 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ansible-core>=2.13.5
ansible-core>=2.16.2
jmespath>=1.0.1
jsonpatch>=1.32
kubernetes>=25.3.0
molecule-vagrant>=1.0.0
molecule>=4.0.3
netaddr>=0.8.0
pre-commit>=2.20.0
pre-commit-hooks>=1.3.1
pyyaml>=6.0
jsonpatch>=1.33
kubernetes>=29.0.0
molecule-plugins[vagrant]
molecule>=6.0.3
netaddr>=0.10.1
pre-commit>=3.6.0
pre-commit-hooks>=4.5.0
pyyaml>=6.0.1
Loading

0 comments on commit e2e9881

Please sign in to comment.