From 5d1b9dc53c91c01c49f587f2f420df8db6bcecfb Mon Sep 17 00:00:00 2001 From: Matthias Leutenegger Date: Thu, 12 Nov 2020 16:12:04 +0100 Subject: [PATCH] add: github workflows (#25) * add: galaxy action * fix var name * run galaxy on very commit * add: molecule action * add: matrix * remove travis * add editor config * beautify * add linter * ansible dir * add: tests * package ecosystem * fix filename * fix --- .editorconfig | 12 +++++ .github/dependabot.yml | 9 ++++ .github/workflows/galaxy.yml | 20 +++++++ .github/workflows/test.yml | 54 +++++++++++++++++++ .travis.yml | 34 ------------ README.md | 5 +- molecule/default/molecule.yml | 12 ++--- molecule/default/playbook.yml | 2 +- molecule/default/test_restic/tasks/main.yml | 9 ++++ .../test_restic/tasks/test_access_files.yml | 18 +++++++ .../test_restic/tasks/test_backup_files.yml | 18 +++++++ .../test_restic/tasks/test_restic_link.yml | 9 ++++ molecule/default/verify.yml | 8 +++ 13 files changed, 168 insertions(+), 42 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/galaxy.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml create mode 100644 molecule/default/test_restic/tasks/main.yml create mode 100644 molecule/default/test_restic/tasks/test_access_files.yml create mode 100644 molecule/default/test_restic/tasks/test_backup_files.yml create mode 100644 molecule/default/test_restic/tasks/test_restic_link.yml create mode 100644 molecule/default/verify.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4a7ea30 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a6611f0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +--- +version: 2 +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: "daily" + assignees: + - 'mleutenegger' diff --git a/.github/workflows/galaxy.yml b/.github/workflows/galaxy.yml new file mode 100644 index 0000000..38ce76e --- /dev/null +++ b/.github/workflows/galaxy.yml @@ -0,0 +1,20 @@ +--- +name: ๐ŸŒŒ Galaxy import + +on: + push: {} + release: + types: + - published + +jobs: + import: + name: ๐Ÿš€ Galaxy Action + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + - name: galaxy + uses: robertdebock/galaxy-action@1.0.3 + with: + galaxy_api_key: ${{ secrets.GALAXY_API_KEY }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..bc52188 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,54 @@ +--- +name: ๐ŸŽญ Tests +on: + push: + paths: + - defaults/** + - handlers/** + - meta/** + - molecule/** + - tasks/** + - templates/** + - vars/** + - .github/** + +jobs: + lint: + name: ๐Ÿ“ Linting + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + fetch-depth: 0 + - name: Lint Code Base + uses: github/super-linter@v3 + env: + VALIDATE_ALL_CODEBASE: false + VALIDATE_ANSIBLE: true + ANSIBLE_DIRECTORY: './' + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + molecule: + name: ๐Ÿงช Molecule test + runs-on: ubuntu-latest + strategy: + matrix: + distro: + - centos7 + - centos6 + - ubuntu1804 + - debian9 + - debian10 + steps: + - name: checkout + uses: actions/checkout@v2 + with: + path: "${{ github.repository }}" + - name: molecule + uses: robertdebock/molecule-action@2.6.3 + env: + MOLECULE_DISTRO: ${{ matrix.distro }} + with: + image: ubuntu diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d657e5b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -language: python -services: docker - -env: - global: - - ROLE_NAME: restic - matrix: - - MOLECULE_DISTRO: centos7 - - MOLECULE_DISTRO: centos6 - - MOLECULE_DISTRO: ubuntu1804 - - MOLECULE_DISTRO: debian9 - - MOLECULE_DISTRO: debian10 - -install: - - pip install molecule docker - - git clone https://github.com/arillso/tests molecule/default/lint - -before_script: - - cd ../ - - mv ansible.$ROLE_NAME arillso.$ROLE_NAME - - cd arillso.$ROLE_NAME - -script: - - molecule test - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ - on_success: always - email: - on_success: never - on_failure: always diff --git a/README.md b/README.md index 03d3d26..13d664c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,10 @@ > **Beta:** This role is in beta status. -[![Build Status](https://img.shields.io/travis/arillso/ansible.restic.svg?branch=master&style=popout-square)](https://travis-ci.org/arillso/ansible.restic) [![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=popout-square)](https://sbaerlo.ch/licence) [![Ansible Galaxy](https://img.shields.io/badge/ansible--galaxy-restic-blue.svg?style=popout-square)](https://galaxy.ansible.com/arillso/restic) [![Ansible Role](https://img.shields.io/ansible/role/d/42773.svg?style=popout-square)](https://galaxy.ansible.com/arillso/restic) +![๐ŸŽญ Tests](https://github.com/arillso/ansible.restic/workflows/%F0%9F%8E%AD%20Tests/badge.svg) +[![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=popout-square)](https://sbaerlo.ch/licence) +[![Ansible Galaxy](https://img.shields.io/badge/ansible--galaxy-restic-blue.svg?style=popout-square)](https://galaxy.ansible.com/arillso/restic) +[![Ansible Role](https://img.shields.io/ansible/role/d/42773.svg?style=popout-square)](https://galaxy.ansible.com/arillso/restic) ## Description [Restic](https://github.com/restic/restic) is a versatile Go based backup diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 062a695..d8c54b7 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -3,9 +3,9 @@ dependency: name: galaxy driver: name: docker -lint: | - set -e - yamllint . +# lint: | +# set -e +# yamllint . platforms: - name: instance image: 'geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest' @@ -16,11 +16,11 @@ platforms: pre_build_image: true provisioner: name: ansible - lint: - name: ansible-lint + # lint: + # name: ansible-lint playbooks: converge: ${MOLECULE_PLAYBOOK:-playbook.yml} scenario: name: default verifier: - name: testinfra + name: ansible diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml index c7567b7..4096d59 100644 --- a/molecule/default/playbook.yml +++ b/molecule/default/playbook.yml @@ -2,7 +2,7 @@ - name: Converge hosts: all roles: - - role: arillso.restic + - role: ansible.restic pre_tasks: - name: install bzip2 package: diff --git a/molecule/default/test_restic/tasks/main.yml b/molecule/default/test_restic/tasks/main.yml new file mode 100644 index 0000000..21e1674 --- /dev/null +++ b/molecule/default/test_restic/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: "include tasks for testing backup files" + include_tasks: "test_backup_files.yml" + +- name: "include tasks for testing access files" + include_tasks: "test_access_files.yml" + +- name: "include tasks for testing restic link" + include_tasks: "test_restic_link.yml" diff --git a/molecule/default/test_restic/tasks/test_access_files.yml b/molecule/default/test_restic/tasks/test_access_files.yml new file mode 100644 index 0000000..5698647 --- /dev/null +++ b/molecule/default/test_restic/tasks/test_access_files.yml @@ -0,0 +1,18 @@ +--- + - name: Stat test access file + stat: + path: ~/restic/access-test.sh + register: test_file + - name: Check that the test access file exists + assert: + that: + - test_file.stat.exists + + - name: Stat test_stdin access file + stat: + path: ~/restic/access-test_stdin.sh + register: test_stdin_file + - name: Check that the test_stdin access file exists + assert: + that: + - test_stdin_file.stat.exists diff --git a/molecule/default/test_restic/tasks/test_backup_files.yml b/molecule/default/test_restic/tasks/test_backup_files.yml new file mode 100644 index 0000000..c2e6f85 --- /dev/null +++ b/molecule/default/test_restic/tasks/test_backup_files.yml @@ -0,0 +1,18 @@ +--- + - name: Stat test backup file + stat: + path: ~/restic/backup-test.sh + register: test_file + - name: Check that the test backup file exists + assert: + that: + - test_file.stat.exists + + - name: Stat test_stdin backup file + stat: + path: ~/restic/backup-test_stdin.sh + register: test_stdin_file + - name: Check that the test_stdin backup file exists + assert: + that: + - test_stdin_file.stat.exists diff --git a/molecule/default/test_restic/tasks/test_restic_link.yml b/molecule/default/test_restic/tasks/test_restic_link.yml new file mode 100644 index 0000000..e6808c9 --- /dev/null +++ b/molecule/default/test_restic/tasks/test_restic_link.yml @@ -0,0 +1,9 @@ +--- + - name: Stat test restic link + stat: + path: ~/restic/restic + register: restic_link + - name: Check that the test restic link exists + assert: + that: + - restic_link.stat.exists diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..b468d1f --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,8 @@ +--- +# This is an example playbook to execute Ansible tests. +- name: Verify + hosts: all + tasks: + - name: "Include test_alpha-services" + include_role: + name: "test_restic"