Skip to content

Commit

Permalink
Merge pull request #7 from manala/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
nervo authored Sep 16, 2024
2 parents 342dfdc + c1ea639 commit 3d79bbe
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 65 deletions.
37 changes: 14 additions & 23 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
file: galaxy.yml
version: version
- name: Get version
id: version
run: |
cat << EOF > $GITHUB_OUTPUT
version=$(make version)
EOF
- name: Build
id: build
Expand All @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
build/
.env.local
galaxy_token
manala-path-*
41 changes: 26 additions & 15 deletions .manala/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,62 @@ 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.
# It's also internally used for checking we're running inside a container.
ENV container="docker"

# Default locale
ENV LANG C.UTF-8
ENV LANG="C.UTF-8"

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .manala/docker/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
build:
context: ..
dockerfile: docker/Dockerfile
image: manala-ansible-path:20240913091855
image: manala-ansible-path:20240916085125
volumes:
- ../..:${MANALA_DIR}
environment:
Expand Down
45 changes: 29 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
########
Expand All @@ -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 \
Expand All @@ -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 \
Expand All @@ -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 \
Expand All @@ -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 \
Expand All @@ -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
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```

Expand All @@ -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
Expand All @@ -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/)
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ build_ignore:
- examples
- galaxy_token
- Makefile
- manala-path-*
- build
- tests

0 comments on commit 3d79bbe

Please sign in to comment.