diff --git a/.ansible-lint.yml b/.ansible-lint.yml new file mode 100644 index 0000000..846d42b --- /dev/null +++ b/.ansible-lint.yml @@ -0,0 +1,9 @@ +--- +skip_list: + - var-naming[no-role-prefix] + - galaxy[no-changelog] + - galaxy[version-incorrect] + - meta-runtime[unsupported-version] +exclude_paths: + - actionlint.yml + - .github/ diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..984b0d9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +# The is primarily used to alter the behaviour of linters executed by super-linter. +# See https://editorconfig.org/ + +# shfmt will default to indenting shell scripts with tabs, +# define the indent as 2 spaces +[bin/*] +indent_style = space +indent_size = 2 diff --git a/.github/linters/actionlint.yml b/.github/linters/actionlint.yml new file mode 120000 index 0000000..766b4e9 --- /dev/null +++ b/.github/linters/actionlint.yml @@ -0,0 +1 @@ +../../actionlint.yml \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..e51c31b --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,47 @@ +--- +name: Lint + +on: # yamllint disable-line rule:truthy + workflow_call: + +permissions: + contents: read + packages: read + # To report GitHub Actions status checks + statuses: write + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + permissions: + contents: read + packages: read + # To report GitHub Actions status checks + statuses: write + + steps: + - uses: actions/checkout@v4 + with: + # super-linter needs the full git history to get the + # list of files that changed across commits + fetch-depth: 0 + submodules: true + + - name: Run ansible-lint + uses: ansible/ansible-lint@v25.4.0 + + - name: Load super-linter configuration + # Use grep inverse matching to exclude eventual comments in the .env file + # because the GitHub Actions command to set environment variables doesn't + # support comments. + # yamllint disable-line rule:line-length + # Ref: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable + run: grep -v '^#' super-linter.env >> "$GITHUB_ENV" + if: always() + + - name: Run super-linter + uses: super-linter/super-linter@v7.3.0 + if: always() + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..d890bff --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,26 @@ +--- + name: Build and test PR + + permissions: + contents: read + packages: read + # To report GitHub Actions status checks + statuses: write + + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + + on: + pull_request: + types: + - opened + - synchronize + - ready_for_review + - reopened + branches: + - main + + jobs: + lint: + uses: ./.github/workflows/lint.yml diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..3220260 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,24 @@ +--- +extends: default + +rules: + brackets: + forbid: non-empty + comments: + # https://github.com/prettier/prettier/issues/6780 + min-spaces-from-content: 1 + # https://github.com/adrienverge/yamllint/issues/384 + comments-indentation: false + document-start: disable + # 160 chars was the default used by old E204 rule, but + # you can easily change it or disable in your .yamllint file. + line-length: + max: 160 + # We are adding an extra space inside braces as that's how prettier does it + # and we are trying not to fight other linters. + braces: + min-spaces-inside: 0 # yamllint defaults to 0 + max-spaces-inside: 1 # yamllint defaults to 0 + octal-values: + forbid-implicit-octal: true # yamllint defaults to false + forbid-explicit-octal: true # yamllint defaults to false diff --git a/README.md b/README.md index 9555444..851ea88 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,20 @@ # caas-repo2docker -This repository adapts [repo2docker](https://repo2docker.readthedocs.io) for use within the +This repository adapts [repo2docker](https://repo2docker.readthedocs.io) for use within the Cluster-as-a-Service system of the [Azimuth Cloud Portal](https://github.com/azimuth-cloud/azimuth). +## Developing locally + +To run the GitHub Actions linters locally, use: + +```sh +docker run --rm \ + -e RUN_LOCAL=true \ + --env-file "super-linter.env" \ + -v "$(pwd)":/tmp/lint \ + ghcr.io/super-linter/super-linter:v7.3.0 +``` + +```sh +ansible-lint -c .ansible-lint.yml +``` diff --git a/actionlint.yml b/actionlint.yml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/actionlint.yml @@ -0,0 +1 @@ +--- diff --git a/ansible.cfg b/ansible.cfg index 9853c5e..aa282bc 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -4,5 +4,5 @@ gathering = smart forks = 30 host_key_checking = False remote_tmp = /tmp -collections_path = collections -roles_path = roles +collections_path = .ansible/collections +roles_path = .ansible/roles diff --git a/repo2docker.yml b/repo2docker.yml index 8c6e673..8d4567f 100644 --- a/repo2docker.yml +++ b/repo2docker.yml @@ -4,15 +4,15 @@ - name: Provision infrastructure hosts: openstack pre_tasks: - - name: Check that Notebook repository URL exists - uri: + - name: Check that Notebook repository URL exists + ansible.builtin.uri: url: "{{ cluster_repository }}" when: (cluster_state | default('present')) == 'present' roles: - cluster_infra - post_tasks: + post_tasks: - name: Wait for Jupyter notebook to become available - uri: + ansible.builtin.uri: url: "http://{{ zenith_fqdn_repo2docker }}" method: GET follow_redirects: safe @@ -29,9 +29,9 @@ delay: 10 until: "repo2docker_uri is not failed" when: (cluster_state | default('present')) == 'present' - + - name: Wait for Monitoring to become available - uri: + ansible.builtin.uri: url: "http://{{ zenith_fqdn_monitoring }}" method: GET follow_redirects: safe diff --git a/roles/cluster_infra/tasks/main.yml b/roles/cluster_infra/tasks/main.yml index 2f6b106..362846f 100644 --- a/roles/cluster_infra/tasks/main.yml +++ b/roles/cluster_infra/tasks/main.yml @@ -1,31 +1,35 @@ --- - name: Install Terraform binary - include_role: + ansible.builtin.include_role: name: azimuth_cloud.terraform.install - name: Make Terraform project directory - file: + ansible.builtin.file: path: "{{ terraform_project_path }}" state: directory + mode: "0755" - name: Write backend type configuration - copy: + ansible.builtin.copy: content: | terraform { backend "{{ terraform_backend_type }}" { } } dest: "{{ terraform_project_path }}/backend.tf" + mode: "0644" - name: Write backend configuration options - copy: + ansible.builtin.copy: content: "{{ terraform_backend_config | to_json }}" dest: "{{ terraform_project_path }}/backend_config.json" + mode: "0644" - name: Template Terraform files into project directory - template: + ansible.builtin.template: src: "{{ item }}.j2" dest: "{{ terraform_project_path }}/{{ item }}" + mode: "0644" loop: - outputs.tf - providers.tf @@ -38,5 +42,5 @@ state: "{{ terraform_state }}" backend_config_files: - "{{ terraform_project_path }}/backend_config.json" - force_init: yes - init_reconfigure: yes + force_init: true + init_reconfigure: true diff --git a/super-linter.env b/super-linter.env new file mode 100644 index 0000000..df2f160 --- /dev/null +++ b/super-linter.env @@ -0,0 +1,14 @@ +# Detect that default branch is devel when running locally +DEFAULT_BRANCH=main + +# Don't validate JSCPD +VALIDATE_JSCPD=false + +# Don't validate JS standard because it conflicts with JS prettier +VALIDATE_JAVASCRIPT_STANDARD=false + +# Don't validate Ansible because ansible-lint is more flexible +VALIDATE_ANSIBLE=false + +# Don't validate YAML prettier because yamllint is sufficient +VALIDATE_YAML_PRETTIER=false diff --git a/ui-meta/repo2docker.yml b/ui-meta/repo2docker.yml index e7ecdd6..92fa5fe 100644 --- a/ui-meta/repo2docker.yml +++ b/ui-meta/repo2docker.yml @@ -1,22 +1,22 @@ name: "repo2docker" label: "Jupyter Notebook" -description: >- - Interactively explore Jupyter Notebooks from an existing GitHub, GitLab, +description: >- + Interactively explore Jupyter Notebooks from an existing GitHub, GitLab, Zenodo or Figshare repository. Powered by repo2docker. -logo: https://raw.githubusercontent.com/jupyter/design/master/logos/Square%20Logo/squarelogo-greytext-orangebody-greymoons/squarelogo-greytext-orangebody-greymoons.png +logo: https://raw.githubusercontent.com/jupyter/design/master/logos/Square%20Logo/squarelogo-greytext-orangebody-greymoons/squarelogo-greytext-orangebody-greymoons.png # yamllint disable-line rule:line-length parameters: - name: cluster_repository label: "Notebook Repository" description: |- Jupyter notebook source repository compatible with - [repo2docker](https://repo2docker.readthedocs.io/en/latest/usage.html#using-repo2docker). + [repo2docker](https://repo2docker.readthedocs.io/en/latest/usage.html#using-repo2docker). Examples are available from [Binder](https://github.com/binder-examples). kind: "string" immutable: true options: placeholder: "e.g. https://github.com/binder-examples/conda" - + - name: cluster_flavor kind: "cloud.size" label: "Jupyter Notebook size" @@ -25,11 +25,11 @@ parameters: options: min_ram: 4096 min_disk: 20 - + - name: cluster_volume_size label: "Volume size (GB)" description: |- - The size of the data volume for the node. + The size of the data volume for the node. The data volume will be available at `/data`. kind: "cloud.volume_size" default: 10 @@ -51,7 +51,7 @@ usage_template: |- services: - name: repo2docker label: Jupyter Notebook - icon_url: https://raw.githubusercontent.com/jupyter/design/master/logos/Square%20Logo/squarelogo-greytext-orangebody-greymoons/squarelogo-greytext-orangebody-greymoons.png + icon_url: https://raw.githubusercontent.com/jupyter/design/master/logos/Square%20Logo/squarelogo-greytext-orangebody-greymoons/squarelogo-greytext-orangebody-greymoons.png # yamllint disable-line rule:line-length - name: monitoring label: Monitoring icon_url: https://raw.githubusercontent.com/cncf/artwork/master/projects/prometheus/icon/color/prometheus-icon-color.png