From 8574e3da1b73fd936ab7bd846242da7da03aa680 Mon Sep 17 00:00:00 2001 From: Emilien Escalle Date: Tue, 26 Mar 2024 12:06:15 +0100 Subject: [PATCH] ci: refactor worflows Signed-off-by: Emilien Escalle --- .github/ISSUE_TEMPLATE/bug_report.md | 40 +++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++ .github/dependabot.yml | 43 ++++++++++++ .github/workflows/__shared-ci.yml | 18 +++++ .github/workflows/__test-action.yml | 73 +++++++++++++++++++++ .github/workflows/__test-nodejs.yml | 12 ++++ .github/workflows/main-ci.yml | 14 ++++ .github/workflows/main.yml | 61 ----------------- .github/workflows/need-fix-to-issue.yml | 21 ++++++ .github/workflows/pull-request-ci.yml | 15 +++++ .github/workflows/semantic-pull-request.yml | 12 ++++ .nvmrc | 1 + action.yml | 10 +-- package.json | 6 +- 14 files changed, 278 insertions(+), 68 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/__shared-ci.yml create mode 100644 .github/workflows/__test-action.yml create mode 100644 .github/workflows/__test-nodejs.yml create mode 100644 .github/workflows/main-ci.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/need-fix-to-issue.yml create mode 100644 .github/workflows/pull-request-ci.yml create mode 100644 .github/workflows/semantic-pull-request.yml create mode 100644 .nvmrc diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..2c6cc29 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,40 @@ +--- +name: Bug report +about: Create a bug report +title: "" +labels: bug, needs triage +assignees: "" +--- + + + + +**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:** + + + +**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. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -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. diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6371f66 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,43 @@ +# 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 + versioning-strategy: widen + schedule: + interval: weekly + day: friday + time: "04:00" + groups: + docker-dependencies: + patterns: + - "*" diff --git a/.github/workflows/__shared-ci.yml b/.github/workflows/__shared-ci.yml new file mode 100644 index 0000000..96935f8 --- /dev/null +++ b/.github/workflows/__shared-ci.yml @@ -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 diff --git a/.github/workflows/__test-action.yml b/.github/workflows/__test-action.yml new file mode 100644 index 0000000..78919cc --- /dev/null +++ b/.github/workflows/__test-action.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/__test-nodejs.yml b/.github/workflows/__test-nodejs.yml new file mode 100644 index 0000000..a228719 --- /dev/null +++ b/.github/workflows/__test-nodejs.yml @@ -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 diff --git a/.github/workflows/main-ci.yml b/.github/workflows/main-ci.yml new file mode 100644 index 0000000..2303cfb --- /dev/null +++ b/.github/workflows/main-ci.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index d73b94a..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/need-fix-to-issue.yml b/.github/workflows/need-fix-to-issue.yml new file mode 100644 index 0000000..3fabf26 --- /dev/null +++ b/.github/workflows/need-fix-to-issue.yml @@ -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 }} diff --git a/.github/workflows/pull-request-ci.yml b/.github/workflows/pull-request-ci.yml new file mode 100644 index 0000000..00e141d --- /dev/null +++ b/.github/workflows/pull-request-ci.yml @@ -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 diff --git a/.github/workflows/semantic-pull-request.yml b/.github/workflows/semantic-pull-request.yml new file mode 100644 index 0000000..7d294fe --- /dev/null +++ b/.github/workflows/semantic-pull-request.yml @@ -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 \ No newline at end of file diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..19c7bdb --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +16 \ No newline at end of file diff --git a/action.yml b/action.yml index 41469ba..da776ca 100644 --- a/action.yml +++ b/action.yml @@ -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: "" diff --git a/package.json b/package.json index debc4b0..f7517b1 100644 --- a/package.json +++ b/package.json @@ -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": "",