ci: refactor worflows

Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
This commit is contained in:
Emilien Escalle 2024-03-26 12:06:15 +01:00
parent c7b6c2f1bf
commit 1a133c6d1c
14 changed files with 277 additions and 68 deletions

40
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,40 @@
---
name: Bug report
about: Create a bug report
title: ""
labels: bug, needs triage
assignees: ""
---
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
<!--- Before opening up a new bug report, please make sure to check for similar existing issues -->
**Description:**
A clear and concise description of what the bug is.
**Action version:**
Specify the action version
**Platform:**
- [ ] Ubuntu
- [ ] macOS
- [ ] Windows
**Runner type:**
- [ ] Hosted
- [ ] Self-hosted
**Tools version:**
<!--- Please specify versions of node and package manager (npm, yarn, pnpm and etc)-->
**Repro steps:**
A description with steps to reproduce the issue. If you have a public example or repository to share, please provide the link.
**Expected behavior:**
A description of what you expected to happen.
**Actual behavior:**
A description of what is actually happening.

View File

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

42
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,42 @@
# This file was generated by the "Generate Dependabot Glob" action. Do not edit it directly.
# Make changes to `.github/dependabot.template.yml` and a PR will be automatically created.
version: 2
updates:
- package-ecosystem: github-actions
directory: /
open-pull-requests-limit: 20
schedule:
interval: weekly
day: friday
time: "04:00"
groups:
github-actions-dependencies:
patterns:
- "*"
- package-ecosystem: npm
directory: "/"
open-pull-requests-limit: 20
versioning-strategy: widen
schedule:
interval: weekly
day: friday
time: "04:00"
groups:
actions-dependencies:
patterns:
- "@actions/*"
npm-dev-dependencies:
dependency-type: development
- package-ecosystem: docker
directory: "/docker"
open-pull-requests-limit: 20
schedule:
interval: weekly
day: friday
time: "04:00"
groups:
docker-dependencies:
patterns:
- "*"

18
.github/workflows/__shared-ci.yml vendored Normal file
View File

@ -0,0 +1,18 @@
name: Common Continuous Integration tasks
on:
workflow_call:
jobs:
linter:
uses: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml@0.12.1
test-nodejs:
name: Test nodejs
needs: linter
uses: ./.github/workflows/__test-nodejs.yml
test-action:
name: Test action
needs: linter
uses: ./.github/workflows/__test-action.yml

73
.github/workflows/__test-action.yml vendored Normal file
View File

@ -0,0 +1,73 @@
name: Internal - Tests for action
on:
workflow_call:
jobs:
test-action-with-services:
runs-on: ubuntu-latest
name: Test compose action
steps:
- uses: actions/checkout@v4
- uses: hoverkraft-tech/ci-github-nodejs/actions/setup-node@0.3.2
- uses: ./
with:
compose-file: "./docker/docker-compose.yml"
services: |
helloworld2
helloworld3
test-action-with-down-flags:
runs-on: ubuntu-latest
name: Test compose action
steps:
- uses: actions/checkout@v4
- uses: hoverkraft-tech/ci-github-nodejs/actions/setup-node@0.3.2
- uses: ./
with:
compose-file: "./docker/docker-compose.yml"
down-flags: "--volumes"
test-action-with-compose-flags:
runs-on: ubuntu-latest
name: Test compose action
steps:
- uses: actions/checkout@v4
- uses: hoverkraft-tech/ci-github-nodejs/actions/setup-node@0.3.2
- uses: ./
with:
compose-file: "./docker/docker-compose.yml"
compose-flags: "--profile profile-1"
down-flags: "--volumes"
test-action-with-env:
runs-on: ubuntu-latest
name: Test compose action
steps:
- uses: actions/checkout@v4
- uses: hoverkraft-tech/ci-github-nodejs/actions/setup-node@0.3.2
- uses: ./
with:
compose-file: "./docker/docker-compose-with-env.yml"
env:
IMAGE_NAME: hello-world
test-action-with-multiple-compose-files:
runs-on: ubuntu-latest
name: Test compose action
steps:
- uses: actions/checkout@v4
- uses: hoverkraft-tech/ci-github-nodejs/actions/setup-node@0.3.2
- uses: ./
with:
compose-file: |
./docker/docker-compose.yml
./docker/docker-compose.ci.yml
services: |
helloworld2
helloworld4

12
.github/workflows/__test-nodejs.yml vendored Normal file
View File

@ -0,0 +1,12 @@
name: Internal - Tests for nodejs
on:
workflow_call:
jobs:
test-nodejs:
uses: hoverkraft-tech/ci-github-nodejs/.github/workflows/continuous-integration.yml@0.3.2
permissions:
id-token: write
security-events: write
contents: read

14
.github/workflows/main-ci.yml vendored Normal file
View File

@ -0,0 +1,14 @@
name: Internal - Main - Continuous Integration
on:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
ci:
uses: ./.github/workflows/__shared-ci.yml
secrets: inherit

View File

@ -1,61 +0,0 @@
on:
workflow_dispatch:
pull_request:
branches:
- main
jobs:
test-compose-action:
runs-on: ubuntu-latest
name: test compose action
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install
- uses: ./
with:
compose-file: "./docker/docker-compose.yml"
services: |
helloworld2
helloworld3
- uses: ./
with:
compose-file: "./docker/docker-compose.yml"
down-flags: "--volumes"
- uses: ./
with:
compose-file: "./docker/docker-compose.yml"
compose-flags: "--profile profile-1"
down-flags: "--volumes"
- uses: ./
with:
compose-file: "./docker/docker-compose-with-env.yml"
env:
IMAGE_NAME: hello-world
- uses: ./
with:
compose-file: |
./docker/docker-compose.yml
./docker/docker-compose.ci.yml
services: |
helloworld2
helloworld4
lint:
runs-on: ubuntu-latest
name: lint test
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install
- name: eslint
run: npm run lint
- name: prettier
run: npm run check-format

21
.github/workflows/need-fix-to-issue.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: Need fix to Issue
on:
push:
branches:
- main
workflow_dispatch:
inputs:
manual-commit-ref:
description: "The SHA of the commit to get the diff for"
required: true
manual-base-ref:
description: "By default, the commit entered above is compared to the one directly before it; to go back further, enter an earlier SHA here"
required: false
jobs:
main:
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@0.12.1
with:
manual-commit-ref: ${{ inputs.manual-commit-ref }}
manual-base-ref: ${{ inputs.manual-base-ref }}

15
.github/workflows/pull-request-ci.yml vendored Normal file
View File

@ -0,0 +1,15 @@
name: Pull request - Continuous Integration
on:
merge_group:
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
ci:
uses: ./.github/workflows/__shared-ci.yml
secrets: inherit

View File

@ -0,0 +1,12 @@
name: "Pull Request - Semantic Lint"
on:
pull_request_target:
types:
- opened
- edited
- synchronize
jobs:
main:
uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@0.11.2

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
16

View File

@ -1,22 +1,22 @@
name: "Docker Compose Action"
description: "Run your docker-compose file"
inputs:
compose-file: # id of input
compose-file:
description: "relative path to compose file(s)"
required: false
default: "./docker-compose.yml"
compose-flags: # id of input
compose-flags:
description: "additional options to pass to `docker-compose` command"
required: false
default: ""
down-flags: # id of input
down-flags:
description: "additional options to pass to `docker-compose down` command"
required: false
default: ""
services: # id of input
services:
description: "services to perform docker-compose up"
required: false
up-flags: # id of input
up-flags:
description: "additional options to pass to `docker-compose up` command"
required: false
default: ""

View File

@ -4,10 +4,12 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "echo \"No test specified\" && exit 1",
"test:ci": "echo \"No test specified\"",
"lint": "eslint .",
"format": "prettier --write \"**/*.{js,json}\"",
"check-format": "prettier --check \"**/*.{js,json}\""
"check-format": "prettier --check \"**/*.{js,json}\"",
"build": "echo \"No build step\""
},
"keywords": [],
"author": "",