Skip to content

Commit

Permalink
Add CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Cook committed Mar 18, 2024
1 parent 730b9e4 commit 1f279b7
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 46 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
name: ci
'on':
pull_request:
push:
branches:
- main

defaults:
run:
working-directory: 'bcook254.vaultwarden'

jobs:

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
with:
path: 'bcook254.vaultwarden'

- name: Set up Python 3.
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install test dependencies.
run: python -m pip install yamllint

- name: Lint code.
run: yamllint .

molecule:
name: Molecule Test
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
with:
path: 'bcook254.vaultwarden'

- name: Set up Python 3.
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install test dependencies.
run: python -m pip install ansible molecule molecule-plugins[docker] docker

- name: Run Molecule tests.
run: molecule test --driver-name docker --scenario-name all
env:
VAULTWARDEN_VERSION: '1.30.5'
VAULTWARDEN_URL: ${{ secrets.VAULTWARDEN_URL }}
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
1 change: 1 addition & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extends: default

ignore: |
molecule/
.github/

rules:
braces:
Expand Down
6 changes: 2 additions & 4 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ galaxy_info:
- 9
- name: Fedora
versions:
- 37
- 38
- 39
- name: Debian
versions:
- bullseye
- bookworm
- name: Ubuntu
versions:
- bionic
- focal
- jammy
galaxy_tags:
- vaultwarden
- bitwardenrs
- bitwarden_rs
1 change: 1 addition & 0 deletions molecule/all/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
hosts: all

vars:
vaultwarden_file: "{{ None if (vaultwarden_url is defined and vaultwarden_url | length > 0) else 'molecule/vaultwarden' }}"
vaultwarden_manage_config: true

roles:
Expand Down
45 changes: 13 additions & 32 deletions molecule/all/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,51 @@ platforms:
- name: ubuntu2204
image: docker.io/geerlingguy/docker-ubuntu2204-ansible
command: ${MOLECULE_DOCKER_COMMAND:-""}
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
cgroupns_mode: host
pre_build_image: true
- name: debian12
image: docker.io/geerlingguy/docker-debian12-ansible
command: ${MOLECULE_DOCKER_COMMAND:-""}
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
cgroupns_mode: host
pre_build_image: true
- name: fedora39
image: docker.io/geerlingguy/docker-fedora39-ansible
command: ${MOLECULE_DOCKER_COMMAND:-""}
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
cgroupns_mode: host
pre_build_image: true
- name: fedora38
image: docker.io/geerlingguy/docker-fedora38-ansible
command: ${MOLECULE_DOCKER_COMMAND:-""}
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
cgroupns_mode: host
pre_build_image: true
- name: centosstream9
image: ghcr.io/bcook254/docker-centosstream9-ansible
command: ${MOLECULE_DOCKER_COMMAND:-""}
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
cgroupns_mode: host
pre_build_image: true
provisioner:
name: ansible
inventory:
group_vars:
all:
vaultwarden_file: 'molecule/vaultwarden'
vaultwarden_version: "${VAULTWARDEN_VERSION}"
vaultwarden_url: "${VAULTWARDEN_URL}"
vaultwarden_url_checksum: "sha256:{{ vaultwarden_url }}.sha256"
host_vars:
centosstream9:
vaultwarden_packages:
Expand All @@ -90,5 +72,4 @@ verifier:
name: ansible
lint: |
set -e
yamllint .
ansible-lint .
2 changes: 1 addition & 1 deletion molecule/all/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
chdir: /usr/local/bin
changed_when: false
register: __vaultwarden_version
failed_when: __vaultwarden_version is not search('1.29.0')
failed_when: __vaultwarden_version is not search(vaultwarden_version if vaultwarden_version | length > 0 else '1.30.5')

- name: Check if Vaultwarden web-vault is installed.
ansible.builtin.stat:
Expand Down
1 change: 1 addition & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
hosts: all

vars:
vaultwarden_file: "{{ None if (vaultwarden_url is defined and vaultwarden_url | length > 0) else 'molecule/vaultwarden' }}"
vaultwarden_manage_config: true

roles:
Expand Down
18 changes: 12 additions & 6 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,27 @@ platforms:
- name: ${MOLECULE_DISTRO:-ubuntu2204}
image: docker.io/geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest
command: ${MOLECULE_DOCKER_COMMAND:-""}
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
privileged: true
cgroupns_mode: host
pre_build_image: true
provisioner:
name: ansible
inventory:
group_vars:
all:
vaultwarden_file: 'molecule/vaultwarden'
vaultwarden_version: "${VAULTWARDEN_VERSION}"
vaultwarden_url: "${VAULTWARDEN_URL}"
vaultwarden_url_checksum: "sha256:{{ vaultwarden_url }}.sha256"
host_vars:
centosstream9:
vaultwarden_packages:
- openssl
- ca-certificates
- curl-minimal
- mariadb-devel
- libpq
config_options:
defaults:
interpreter_python: auto_silent
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
chdir: /usr/local/bin
changed_when: false
register: __vaultwarden_version
failed_when: __vaultwarden_version is not search('1.29.0')
failed_when: __vaultwarden_version is not search(vaultwarden_version if vaultwarden_version | length > 0 else '1.30.5')

- name: Check if Vaultwarden web-vault is installed.
ansible.builtin.stat:
Expand Down
2 changes: 1 addition & 1 deletion tasks/assertions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
- name: Check either vaultwarden_url or vaultwarden_file is set.
ansible.builtin.assert:
that:
- vaultwarden_url is defined or vaultwarden_file is defined
- (vaultwarden_url is defined and vaultwarden_url | length > 0) or (vaultwarden_file is defined and vaultwarden_file | length > 0)
fail_msg: "One of 'vaultwarden_url' or 'vaultwarden_file' must be set."
quiet: true
2 changes: 2 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
notify: restart vaultwarden
when:
- vaultwarden_url is defined
- vaultwarden_url | length > 0

- name: Install Vaultwarden (Local).
ansible.builtin.copy:
Expand All @@ -38,6 +39,7 @@
notify: restart vaultwarden
when:
- vaultwarden_file is defined
- vaultwarden_file | length > 0

- name: Ensure Vaultwarden data directory exists.
ansible.builtin.file:
Expand Down
1 change: 0 additions & 1 deletion tasks/setup-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
name: "{{ vaultwarden_packages }}"
state: present
update_cache: true
cache_valid_time: 43200

0 comments on commit 1f279b7

Please sign in to comment.