Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin python dependencies and optimize GitHub Actions #811

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions .github/workflows/mysql_hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,14 @@ jobs:
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: 3.12
cache: 'pip'

- name: Install dependencies
run: |
sudo apt install git
python -m pip install --no-cache-dir --upgrade pip
pip install -r requirements.txt
run: pip install -r requirements.txt
working-directory: ansible_collections/devsec/hardening

- name: Downgrade Ansible for Rocky 8 tests
run: |
pip install "ansible-core<2.17"
run: pip install "ansible-core<2.17"
working-directory: ansible_collections/devsec/hardening
if: matrix.molecule_distro == 'rocky8'

Expand All @@ -96,9 +93,7 @@ jobs:
/home/runner/.ansible/roles

- name: Test with molecule
run: |
molecule --version
molecule test -s mysql_hardening
run: molecule test -s mysql_hardening
env:
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}
working-directory: ansible_collections/devsec/hardening
13 changes: 4 additions & 9 deletions .github/workflows/nginx_hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,14 @@ jobs:
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: 3.12
cache: 'pip'

- name: Install dependencies
run: |
sudo apt install git
python -m pip install --no-cache-dir --upgrade pip
pip install -r requirements.txt
run: pip install -r requirements.txt
working-directory: ansible_collections/devsec/hardening

- name: Downgrade Ansible for Rocky 8 tests
run: |
pip install "ansible-core<2.17"
run: pip install "ansible-core<2.17"
working-directory: ansible_collections/devsec/hardening
if: matrix.molecule_distro == 'rocky8'

Expand All @@ -85,9 +82,7 @@ jobs:
/home/runner/.ansible/roles

- name: Test with molecule
run: |
molecule --version
molecule test -s nginx_hardening
run: molecule test -s nginx_hardening
env:
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}
working-directory: ansible_collections/devsec/hardening
23 changes: 10 additions & 13 deletions .github/workflows/os_hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
- molecule_distro: opensuse_tumbleweed
molecule_docker_command: "/usr/lib/systemd/systemd"
molecule_distro:
- centosstream9
- rocky8
Expand All @@ -47,8 +50,9 @@ jobs:
- debian11
- debian12
- amazon2023
- opensuse_tumbleweed
- arch
molecule_docker_command:
- "/lib/systemd/systemd"
steps:
- name: Checkout repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
Expand All @@ -60,27 +64,20 @@ jobs:
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: 3.12
cache: 'pip'

- name: Install dependencies
run: |
sudo apt install git
python -m pip install --no-cache-dir --upgrade pip
pip install -r requirements.txt
run: pip install -r requirements.txt
working-directory: ansible_collections/devsec/hardening

- name: Downgrade Ansible for Rocky 8 tests
run: |
pip install "ansible-core<2.17"
run: pip install "ansible-core<2.17"
working-directory: ansible_collections/devsec/hardening
if: matrix.molecule_distro == 'rocky8'

- name: Test with molecule
run: |
if [ "$MOLECULE_DISTRO" = "opensuse_tumbleweed" ]; then
export MOLECULE_DOCKER_COMMAND="/usr/lib/systemd/systemd"
fi
molecule --version
molecule test -s os_hardening
run: molecule test -s os_hardening
env:
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}
MOLECULE_DOCKER_COMMAND: ${{ matrix.molecule_docker_command }}
working-directory: ansible_collections/devsec/hardening
1 change: 0 additions & 1 deletion .github/workflows/os_hardening_vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ jobs:
- name: Test with molecule
run: |
source ~/.venv/ansible-collection-hardening/bin/activate
molecule --version
molecule test -s os_hardening_vm
env:
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/roles-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on: # yamllint disable-line rule:truthy
paths:
- 'roles/**/meta/argument_specs.yml'
- 'roles/**/meta/main.yml'
- 'requirements.txt'

jobs:
readme:
Expand All @@ -32,12 +33,13 @@ jobs:
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: 3.12
cache: 'pip'

- name: Install aar_doc
run: pip3 install aar_doc
- name: Install dependencies
run: pip install -r requirements.txt

- name: Run aar_doc
run: aar_doc roles/${{ matrix.roles }} markdown
- name: Run aar-doc
run: aar-doc roles/${{ matrix.roles }} markdown

- name: Output diff
run: git diff roles/${{ matrix.roles }}/README.md
Expand Down
17 changes: 6 additions & 11 deletions .github/workflows/ssh_hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ jobs:
# molecule_docker_command: "/usr/lib/systemd/systemd"
- molecule_distro: alpine
molecule_docker_command: "/sbin/init"
molecule_docker_command:
- "/lib/systemd/systemd"
molecule_distro:
- centosstream9
- rocky8
Expand All @@ -56,6 +54,8 @@ jobs:
- debian12
- amazon2023
- arch
molecule_docker_command:
- "/lib/systemd/systemd"
steps:
- name: Checkout repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
Expand All @@ -67,24 +67,19 @@ jobs:
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: 3.12
cache: 'pip'

- name: Install dependencies
run: |
sudo apt install git
python -m pip install --no-cache-dir --upgrade pip
pip install -r requirements.txt
run: pip install -r requirements.txt
working-directory: ansible_collections/devsec/hardening

- name: Downgrade Ansible for Rocky 8 tests
run: |
pip install "ansible-core<2.17"
run: pip install "ansible-core<2.17"
working-directory: ansible_collections/devsec/hardening
if: matrix.molecule_distro == 'rocky8'

- name: Test with molecule
run: |
molecule --version
molecule test -s ssh_hardening
run: molecule test -s ssh_hardening
env:
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}
MOLECULE_DOCKER_COMMAND: ${{ matrix.molecule_docker_command }}
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/ssh_hardening_bsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,10 @@ jobs:
submodules: true

- name: Update Vagrant Box
run: |
vagrant box update --box generic/${{ matrix.molecule_distro }} || true
run: vagrant box update --box generic/${{ matrix.molecule_distro }} || true

- name: Test with molecule
run: |
molecule --version
molecule test -s ssh_hardening_bsd
run: molecule test -s ssh_hardening_bsd
env:
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}
working-directory: ansible_collections/devsec/hardening
17 changes: 6 additions & 11 deletions .github/workflows/ssh_hardening_custom_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ jobs:
# molecule_docker_command: "/usr/lib/systemd/systemd"
- molecule_distro: alpine
molecule_docker_command: "/sbin/init"
molecule_docker_command:
- "/lib/systemd/systemd"
molecule_distro:
- centosstream9
- rocky8
Expand All @@ -56,6 +54,8 @@ jobs:
- debian12
- amazon2023
- arch
molecule_docker_command:
- "/lib/systemd/systemd"
steps:
- name: Checkout repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
Expand All @@ -67,24 +67,19 @@ jobs:
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: 3.12
cache: 'pip'

- name: Install dependencies
run: |
sudo apt install git
python -m pip install --no-cache-dir --upgrade pip
pip install -r requirements.txt
run: pip install -r requirements.txt
working-directory: ansible_collections/devsec/hardening

- name: Downgrade Ansible for Rocky 8 tests
run: |
pip install "ansible-core<2.17"
run: pip install "ansible-core<2.17"
working-directory: ansible_collections/devsec/hardening
if: matrix.molecule_distro == 'rocky8'

- name: Test with molecule
run: |
molecule --version
molecule test -s ssh_hardening_custom_tests
run: molecule test -s ssh_hardening_custom_tests
env:
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}
MOLECULE_DOCKER_COMMAND: ${{ matrix.molecule_docker_command }}
Expand Down
12 changes: 5 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
molecule
molecule-plugins[docker]
yamllint
molecule==24.9.0
molecule-plugins[docker]==23.5.3
ansible-core==2.17.5
ansible-lint
docker
flake8
jmespath
docker==7.1.0
jmespath==1.0.1
aar-doc==2.0.0
Loading