Skip to content

Commit

Permalink
Merge pull request #811 from dev-sec/py_version
Browse files Browse the repository at this point in the history
Pin python dependencies and optimize GitHub Actions
  • Loading branch information
schurzi authored Oct 22, 2024
2 parents 7dab72c + 92995bb commit b6d11a0
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 70 deletions.
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

0 comments on commit b6d11a0

Please sign in to comment.