diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 799711c..662380d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -12,32 +12,24 @@ jobs: if: github.event.head_commit.message == 'Release' steps: - - name: Notify Slack - Starting - uses: act10ns/slack@v2 - with: - status: starting - channel: '#collection_release' - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - name: Checkout uses: actions/checkout@v4 - name: Set ansible galaxy token run: | - cat << EOF > ./galaxy_token + cat << EOF > galaxy_token token: ${{ secrets.ANSIBLE_GALAXY_TOKEN }} EOF - name: Set up system uses: ./.manala/github/system/setup - - name: Get metadata from galaxy.yml - id: metadata - uses: CumulusDS/get-yaml-paths-action@v1.0.2 - with: - file: galaxy.yml - version: version + - name: Get version + id: version + run: | + cat << EOF > $GITHUB_OUTPUT + version=$(make version) + EOF - name: Build id: build @@ -47,9 +39,8 @@ jobs: - name: Upload build artifact uses: actions/upload-artifact@v4 with: - path: ./manala-path-${{ steps.metadata.outputs.version }}.tar.gz - name: manala-path-${{ steps.metadata.outputs.version }} - retention-days: 1 + path: build/manala-path-${{ steps.version.outputs.version }}.tar.gz + name: manala-path-${{ steps.version.outputs.version }}.tar.gz - name: Publish id: publish @@ -60,17 +51,17 @@ jobs: id: changelog uses: mindsers/changelog-reader-action@v2 with: - path: ./CHANGELOG.md - version: ${{ steps.metadata.outputs.version }} + path: CHANGELOG.md + version: ${{ steps.version.outputs.version }} - name: Create GitHub Release id: release uses: ncipollo/release-action@v1 with: - name: manala-path ${{ steps.metadata.outputs.version }} - tag: ${{ steps.metadata.outputs.version }} + name: ${{ steps.version.outputs.version }} + tag: ${{ steps.version.outputs.version }} body: ${{ steps.changelog.outputs.changes }} - artifacts: ./manala-path-${{ steps.metadata.outputs.version }}.tar.gz + artifacts: build/manala-path-${{ steps.version.outputs.version }}.tar.gz token: ${{ secrets.GITHUB_TOKEN }} skipIfReleaseExists: true diff --git a/.gitignore b/.gitignore index 97c0357..5d3c568 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ +build/ .env.local galaxy_token -manala-path-* diff --git a/.manala/docker/Dockerfile b/.manala/docker/Dockerfile index 2e51351..174dfdb 100644 --- a/.manala/docker/Dockerfile +++ b/.manala/docker/Dockerfile @@ -12,6 +12,8 @@ ARG MANALA_GROUP_ID="1000" ARG GOSU_VERSION="1.17" ARG GOMPLATE_VERSION="4.1.0" ARG DIRENV_VERSION="2.34.0" +ARG JQ_VERSION="1.7.1" +ARG YQ_VERSION="4.44.3" # The 'container' environment variable tells systemd that it's running inside a # Docker container environment. @@ -19,7 +21,7 @@ ARG DIRENV_VERSION="2.34.0" ENV container="docker" # Default locale -ENV LANG C.UTF-8 +ENV LANG="C.UTF-8" SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -27,36 +29,45 @@ RUN \ apt-get --quiet update \ && apt-get --quiet --yes --purge --autoremove upgrade \ && apt-get --quiet --yes --no-install-recommends --verbose-versions install \ - s6 \ - sudo \ - curl \ - ca-certificates \ - gnupg \ - libarchive-tools bzip2 \ bash-completion \ - rsync \ + bzip2 \ + ca-certificates \ + curl \ git \ - make \ + gnupg \ less \ - vim \ + libarchive-tools \ + make \ + rsync \ + s6 \ socat \ + sudo \ + vim \ # User && addgroup --gid ${MANALA_GROUP_ID} lazy \ && adduser --home /home/lazy --shell /bin/bash --uid ${MANALA_USER_ID} --gecos lazy --ingroup lazy --disabled-password lazy \ && install --verbose --mode 0755 --group lazy --owner lazy --directory /run/user/${MANALA_USER_ID} \ && echo "lazy ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/lazy \ # Gosu - && curl -sSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ + && curl -sSLf "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ --output /usr/local/bin/gosu \ && chmod +x /usr/local/bin/gosu \ # Gomplate - && curl -sSL "https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ + && curl -sSLf "https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ --output /usr/local/bin/gomplate \ && chmod +x /usr/local/bin/gomplate \ # Direnv - && curl -sSL "https://github.com/direnv/direnv/releases/download/v${DIRENV_VERSION}/direnv.linux-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ + && curl -sSLf "https://github.com/direnv/direnv/releases/download/v${DIRENV_VERSION}/direnv.linux-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ --output /usr/local/bin/direnv \ && chmod +x /usr/local/bin/direnv \ + # Jq + && curl -sSLf "https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/jq-linux-$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ + --output /usr/local/bin/jq \ + && chmod +x /usr/local/bin/jq \ + # Yq + && curl -sSLf "https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_$(case $(dpkg --print-architecture) in "amd64") echo "amd64" ;; "arm64") echo "arm64" ;; esac)" \ + --output /usr/local/bin/yq \ + && chmod +x /usr/local/bin/yq \ # Bash completion && install --verbose --mode 0755 --directory /etc/bash_completion.d \ # Oh My Bash @@ -75,11 +86,11 @@ RUN \ apt-get --quiet update \ && apt-get --quiet --yes --no-install-recommends --verbose-versions install \ openssh-client \ - sshpass \ - python3 \ pipx \ + python3 \ python3-argcomplete \ shellcheck \ + sshpass \ # Sudo && echo "Defaults env_keep += \"PIPX_*\"" > /etc/sudoers.d/pipx \ # Bash completion diff --git a/.manala/docker/compose.yaml b/.manala/docker/compose.yaml index a445a65..b1677d2 100644 --- a/.manala/docker/compose.yaml +++ b/.manala/docker/compose.yaml @@ -11,7 +11,7 @@ services: build: context: .. dockerfile: docker/Dockerfile - image: manala-ansible-path:20240913091855 + image: manala-ansible-path:20240916085125 volumes: - ../..:${MANALA_DIR} environment: diff --git a/Makefile b/Makefile index cf86094..798b6cf 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,20 @@ include .manala/Makefile +NAMESPACE = manala +COLLECTION = path +VERSION = $(shell yq '.version' galaxy.yml) + +########### +# Version # +########### + +## Version - Get collection version +version: SHELL := $(MANALA_DOCKER_SHELL) +version: + printf $(VERSION) +.PHONY: version + ######## # Lint # ######## @@ -18,11 +32,11 @@ lint: # Test # ######## -## Test - Run all tests (but doc and coverage) +## Test - Run all collection tests (but doc and coverage) test: test.sanity test.units test.integration .PHONY: test -## Test - Run sanity tests [VERBOSE] +## Test - Run collection sanity tests [VERBOSE] test.sanity: SHELL := $(MANALA_DOCKER_SHELL) test.sanity: ansible-test sanity \ @@ -35,7 +49,7 @@ test.sanity: --exclude .manala/ .PHONY: test.sanity -## Test - Run units tests [VERBOSE|COVERAGE] +## Test - Run collection units tests [VERBOSE|COVERAGE] test.units: SHELL := $(MANALA_DOCKER_SHELL) test.units: ansible-test units \ @@ -47,7 +61,7 @@ test.units: --color yes .PHONY: test.units -## Test - Run integration tests [VERBOSE|COVERAGE] +## Test - Run collection integration tests [VERBOSE|COVERAGE] test.integration: SHELL := $(MANALA_DOCKER_SHELL) test.integration: ansible-test integration \ @@ -59,20 +73,20 @@ test.integration: --color yes .PHONY: test.integration -## Test - Run documentation tests [VERBOSE] +## Test - Run collection documentation tests [VERBOSE] test.doc: SHELL := $(MANALA_DOCKER_SHELL) test.doc: $(foreach type,module filter, \ - $(foreach plugin,$(shell ansible-doc --list manala.path --type $(type) | cut -d " " -f 1), \ + $(foreach plugin,$(shell ansible-doc --list $(NAMESPACE).$(COLLECTION) --type $(type) --json | jq --raw-output 'keys[]'), \ ansible-doc \ $(if $(VERBOSE), --verbose) \ --type $(type) \ - $(plugin) && \ + $(plugin) > /dev/null && \ ) \ ) true .PHONY: test.doc -## Test - Run coverage [VERBOSE] +## Test - Run collection coverage [VERBOSE] test.coverage: SHELL := $(MANALA_DOCKER_SHELL) test.coverage: ansible-test coverage xml \ @@ -89,20 +103,19 @@ test.coverage: # Build / Publish # ################### -COLLECTION = manala-path-*.tar.gz - -## Build - Build collection +## Build - Build collection [VERBOSE] build: SHELL := $(MANALA_DOCKER_SHELL) build: - rm -rfv $(COLLECTION) ansible-galaxy collection build \ - $(if $(VERBOSE), --verbose) \ - --force + --output-path build \ + --force \ + $(if $(VERBOSE), --verbose) + .PHONY: build -## Collection - Publish collection +## Publish - Publish collection [VERBOSE] publish: SHELL := $(MANALA_DOCKER_SHELL) publish: - ansible-galaxy collection publish $(COLLECTION) \ + ansible-galaxy collection publish build/$(NAMESPACE)-$(COLLECTION)-$(VERSION).tar.gz \ $(if $(VERBOSE), --verbose) .PHONY: publish diff --git a/README.md b/README.md index 0fdf1e2..3679a9a 100644 --- a/README.md +++ b/README.md @@ -30,10 +30,10 @@ Note that if you install the collection from Ansible Galaxy, it will not be upgr ansible-galaxy collection install manala.path --upgrade ``` -You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax to install version `1.0.0`: +You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax to install version `1.1.0`: ```shell -ansible-galaxy collection install manala.path:==1.0.0 +ansible-galaxy collection install manala.path:==1.1.0 ``` ### Installing the Collection from Github @@ -48,7 +48,7 @@ In case of unavailability of ansible-galaxy, we host a tar.gz of every version o - requirements.yaml: ```yaml collections: - - name: https://github.com/manala/ansible-path/releases/download/$VERSION/manala-roles-$VERSION.tar.gz + - name: https://github.com/manala/ansible-path/releases/download/$VERSION/manala-path-$VERSION.tar.gz type: url ``` @@ -68,11 +68,10 @@ Found a bug ? Please open an [issue](https://github.com/manala/ansible-path/issu You can contact us [here](manala-io.slack.com) -Any kind of contribution is very welcome, you can submit pull requests [here](https://github.com/manala/ansible-roles/pulls) +Any kind of contribution is very welcome, you can submit pull requests [here](https://github.com/manala/ansible-path/pulls) -This collection uses [molecule](https://github.com/ansible-community/molecule), [ansible-lint](https://github.com/ansible-community/ansible-lint), and `ansible-test` for linting and testing roles. +This collection uses [ansible-lint](https://github.com/ansible-community/ansible-lint), and `ansible-test` for linting and testing roles. -All of these tools are available through the excellent [ansible-toolset](https://github.com/ansible-community/toolset) docker image. Open a docker shell ```shell @@ -96,8 +95,8 @@ ansible-test units --python 3.11 tests/unit/plugins/lookup/test_foo.py This collection is distributed under the MIT license. -See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. +See [LICENSE](LICENSE) to see the full text. # Author information -Manala [**(http://www.manala.io/)**](http://www.manala.io) +Manala [**(https://www.manala.io/)**](https://www.manala.io/) diff --git a/galaxy.yml b/galaxy.yml index 72aa869..40b87df 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -67,5 +67,5 @@ build_ignore: - examples - galaxy_token - Makefile - - manala-path-* + - build - tests