Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sbaerlocher committed Jul 26, 2022
1 parent 9cb69ac commit 9f749af
Show file tree
Hide file tree
Showing 28 changed files with 1,658 additions and 1,485 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.git
.github
.gitignore
.idea
.vscode
.devcontainer
.prettierrc.json
CHANGELOG.md
fake_collection
node_modules
coverage
26 changes: 26 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,29 @@ updates:
prefix: fix
prefix-development: chore
include: scope

- package-ecosystem: docker
directory: "/"
schedule:
interval: monthly
reviewers:
- sbaerlocher
assignees:
- sbaerlocher
commit-message:
prefix: fix
prefix-development: chore
include: scope

- package-ecosystem: pip
directory: "/"
schedule:
interval: monthly
reviewers:
- sbaerlocher
assignees:
- sbaerlocher
commit-message:
prefix: fix
prefix-development: chore
include: scope
66 changes: 0 additions & 66 deletions .github/settings.yml

This file was deleted.

118 changes: 118 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Testing the Action

on: [pull_request]

env:
RUNNER_TEMP: /tmp
TEST_ARTIFACT_VERSION: 0.0.14

jobs:
local_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- uses: actions/setup-node@v3
with:
node-version-file: .node-version
cache: 'npm'
check-latest: true

- name: Install Dependencies
run: npm ci

- name: Check Format
run: npm run format-check

- name: Run tests
run: npm test

test_deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]

- name: Set up action.yml
run: cp action_ci.yml action.yml

- name: Test the action
uses: ./
with:
api_key: '${{ secrets.GALAXY_API_KEY }}'
# Fake location that's a small amount of content
collection_dir: 'tests/collection'

- name: Test the action with a custom version
uses: ./
with:
api_key: '${{ secrets.GALAXY_API_KEY }}'
collection_dir: 'tests/collection'
# Custom version
galaxy_version: '${{ env.TEST_ARTIFACT_VERSION }}-test'

test_build_then_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- name: Set up action.yml
run: cp tests/action.yml action.yml

- name: Test the action - only build
uses: ./
with:
api_key: '${{ secrets.GALAXY_API_KEY }}'
collection_dir: 'tests/collection'
# Different from above version
galaxy_version: '${{ env.TEST_ARTIFACT_VERSION }}-build'
build: true
publish: false

- name: Test the action - only publish
uses: ./
with:
api_key: '${{ secrets.GALAXY_API_KEY }}'
collection_dir: 'tests/collection'
# Should match version above
galaxy_version: '${{ env.TEST_ARTIFACT_VERSION }}-build'
build: false
publish: true

snapshot:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- name: Set up Docker Buildx
uses: docker/[email protected]
with:
install: true

- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/[email protected]
with:
images: |
ghcr.io/arillso/action-ansible-collection-testartifact
tags: |
type=raw,value=SNAPSHOT-${{ github.sha }}
- name: Build and Push
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64
file: ./Dockerfile
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
65 changes: 65 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
on:
release:
types:
- published

env:
IMAGE_NAME: arillso/action-ansible-collection

name: Release
jobs:
release:
name: Release GitHub Actions
runs-on: ubuntu-latest
steps:
- name: Semver release
uses: technote-space/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CLEAN_TARGETS: ''

deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]

- name: Get the version
run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
uses: docker/[email protected]
with:
install: true

- name: Docker meta
id: meta
uses: docker/[email protected]
with:
images: |
ghcr.io/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=raw,value=${{ env.RELEASE_VERSION }}
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64, linux/arm64
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
19 changes: 0 additions & 19 deletions .github/workflows/test.yml

This file was deleted.

1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
17 changes: 8 additions & 9 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript"
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "avoid"
}
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM node:18-slim AS builder

WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . ./
RUN npm run build

FROM node:18-slim AS runner

# Required for python inside Docker containers
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends python3 python3-pip python3-setuptools python3-wheel \
# Slim down layer size
&& apt-get autoremove -y \
&& apt-get autoclean -y \
# Remove apt-get cache from the layer to reduce container size
&& rm -rf /var/lib/apt/lists/*

RUN npm install -g npm \
&& python3 -m pip install --no-cache-dir --upgrade pip

WORKDIR /app

COPY requirements.txt ./
RUN python3 -m pip install --no-cache-dir -r requirements.txt

COPY --from=builder /app/dist ./dist
COPY package*.json ./
RUN npm ci --production \
&& npm cache clean --force

ENTRYPOINT ["node", "/app/dist/main.js"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ This project is under the MIT License. See the [LICENSE](licence) file for the f
## Copyright
(c) 2020, Arillso
(c) 2022, Arillso
Loading

0 comments on commit 9f749af

Please sign in to comment.