Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring: typescript #83

Merged
merged 83 commits into from
Jul 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
fbc69a5
feature: introduce ESLint
boesing Mar 16, 2022
fb30cea
bugfix: surround string value when it contains colon
boesing Mar 16, 2022
aa84618
bugfix: provide working github workflow
boesing Mar 16, 2022
003998e
qa: remove `node-version` from `actions/setup-node` to always install…
boesing Mar 16, 2022
f5553e5
bugfix: remove empty-object annotations
boesing Mar 16, 2022
baaa240
qa: switch to `npm ci`
boesing Mar 16, 2022
f1b03b7
qa: revert weird spacing for `${}` surrounded variables/function calls
boesing Mar 16, 2022
48095e1
qa: remove `@babel/eslint-parser`
boesing Mar 16, 2022
4aac396
qa: use node v17 rather than `current`
boesing Mar 16, 2022
8ee9057
refactoring: convert application to typescript
boesing Mar 24, 2022
74fb8c1
bugfix: add `tsconfig.json` as `tsconfig.json`
boesing Mar 25, 2022
cb10195
bugfix: use script from `package.json` to run linting
boesing Mar 25, 2022
eb6b330
qa: add `noUncheckedIndexedAccess`
boesing Apr 6, 2022
5e7a03f
qa: remove unnecessary constant
boesing Apr 6, 2022
fbc95b5
qa: add `pattern` to `php` JSON schema
boesing Apr 6, 2022
58b1d3a
feature: deduplicate the generated additional checks
boesing Apr 6, 2022
1b9a171
Remove all linting issues
boesing Apr 6, 2022
08f6446
Remove spaces added by `eslint --fix`
boesing Apr 6, 2022
5f05c4c
Rename `createConfig` to `createConfigObject` to better reflect what …
boesing Apr 6, 2022
4844cfa
Use `tilde` operator to pin typescript to a patch version
boesing Apr 6, 2022
3d26831
refactoring: remove `Logger` interface from `Action` interface
boesing Apr 6, 2022
dd08b2e
qa: remove redundant constant
boesing Apr 6, 2022
efa360d
refactor: rename `ComposerDependency` to `ComposerDependencySet`
boesing Apr 6, 2022
6dd19e6
feature: split docker build into multi-layer build
boesing Apr 6, 2022
dd2c736
feature: build container within CI
boesing Apr 6, 2022
622fef4
bugfix: do not login in CI
boesing Apr 6, 2022
58d84bf
feature: download composer JSON schema from getcomposer.org
boesing Apr 6, 2022
0677ce1
bugfix: convert file buffer to string before parsing to JSON
boesing Apr 6, 2022
2e6bc45
bugfix: use enum for `php` property within a `job`
boesing Jun 8, 2022
9ad85b9
qa: normalize `continuous-integration.yml`
boesing Jun 28, 2022
a3c96a0
qa: disable `@typescript-eslint/no-inferrable-types` as we stricter i…
boesing Jun 28, 2022
564297f
qa: disable `object-shorthand` check as we do want to be more explicit
boesing Jun 28, 2022
47bcf43
qa: optimize `eslint` and fixed some issues
boesing Jun 28, 2022
d5df1f8
qa: remove unnecessary annotations
boesing Jun 28, 2022
20b452c
bugfix: remove possibly unused `awesome-typescript-loader`
boesing Jun 28, 2022
bf0b3ae
bugfix: tell docker container within GHA that it is actually a GHA
boesing Jun 28, 2022
487adaf
bugfix: pass all host environment variables to the container
boesing Jun 28, 2022
71b77af
enhancement: use `GITHUB_ACTIONS` environment variable rather than `G…
boesing Jun 28, 2022
1ee4905
docs: add some description on why we do use `GITHUB_ACTIONS` environm…
boesing Jun 28, 2022
8846628
bugfix: remove `GITHUB_ACTIONS` environment variable from CI as we do…
boesing Jun 28, 2022
99dbef9
bugfix: ensure `latest` dependencies for projects without `composer.l…
boesing Jun 28, 2022
e6c66e9
bugfix: `No checks` check always contains static `locked`
boesing Jun 28, 2022
65e619d
qa: add integration test for project with `composer.lock`
boesing Jun 28, 2022
6ad9784
revert: change back to `diff` so we get more readable output
boesing Jun 28, 2022
55b78ce
feature: add PHP version and composer dependency set to output check …
boesing Jun 28, 2022
32be08b
bugfix: restore initial `diff` command
boesing Jun 28, 2022
677e816
qa: add integration tests for `exclude` to verify projects can exclud…
boesing Jun 28, 2022
db517d5
qa: rework `sanityChecksPassing` to do `assertions` rather than alway…
boesing Jun 28, 2022
b323d65
bugfix: remove unnecessary `node` call from CI as it pollutes the diff
boesing Jun 29, 2022
deef576
qa: remove unnecessary variable `REQUIRE_CHECKS=true` from `entrypoin…
boesing Jun 29, 2022
5d9ce00
feature: use `webpack.BannerPlugin` to add shebang to generated `main…
boesing Jun 29, 2022
90a5198
feature: output files used for generating the configuration via `debug`
boesing Jun 29, 2022
08430d2
qa: create test to verify that we do not run code checks for docs onl…
boesing Jun 29, 2022
8364da0
qa: add test for code checks without linting even tho the markdown fi…
boesing Jun 29, 2022
1c2d551
qa: add integration test for `.laminas-ci.json` change
boesing Jun 29, 2022
f06c9f2
qa: ensure that we do not run any check if non-PHP and non-markdown f…
boesing Jun 29, 2022
636648f
bugfix: use more readable length check
boesing Jun 29, 2022
6ff3cb8
bugfix: do not run docker with `-t` since we are not in a TTY
boesing Jun 29, 2022
4e56746
bugfix: show proper step name within job
boesing Jun 29, 2022
b5afb6d
bugfix: add backwards compatibility for old job exclusions
boesing Jun 29, 2022
f347807
docs: update `exclude` examples to reflect latest changes
boesing Jun 29, 2022
4e524e5
qa: enhance deprecated exclusion test
boesing Jun 29, 2022
ea158df
qa: enhance exclusion test
boesing Jun 29, 2022
49120eb
bugfix: fix tool name in expected matrix output
boesing Jun 29, 2022
41ebcfa
bugfix: ensure that job definitions are always created via `createJob`
boesing Jun 29, 2022
73bc9c3
qa: we should expect `latest` in projects without `composer.lock`
boesing Jun 29, 2022
c7439e2
bugfix: ensure that expected matrix is generated as expected by addin…
boesing Jun 29, 2022
ff69543
bugfix: initialize variable before pushing
boesing Jun 29, 2022
124c789
bugfix: `No checks` check will not provide PHP or composer dependency…
boesing Jun 29, 2022
5871d45
bugfix: ensure tests properly reflect what we do want to verify
boesing Jun 29, 2022
227a98e
bugfix: ensure backwards compatibility for deprecated exclusions
boesing Jun 29, 2022
b1737c8
bugfix: provide tool information via job to provide backwards compati…
boesing Jun 29, 2022
450e390
bugfix: properly detected `@latest` and `@lowest` from job definition…
boesing Jun 29, 2022
cbd2a8f
qa: ensure line-length is not exceeded
boesing Jun 29, 2022
b66d3b1
bugfix: we do have `locked` dependencies and thus we should expect `l…
boesing Jun 29, 2022
f794686
bugfix: wrap ternary operation in brackets
boesing Jun 29, 2022
972aa8d
qa: expected output should not double quote the job
boesing Jun 29, 2022
7f9306f
bugfix: since no `composer.lock` is available, we do expect `latest` …
boesing Jun 29, 2022
c9676b4
bugfix: PHP 8.0 platform requirements are not ignored by default anymore
boesing Jun 29, 2022
ad517a1
bugfix: ensure we properly validate the `.laminas-ci.json` with the `…
boesing Jun 30, 2022
f089a42
bugfix: allow `@lowest` and `@latest` for `php` information within th…
boesing Jun 30, 2022
081d677
bugfix: use proper `composer.schema.json` name
boesing Jun 30, 2022
6733c63
qa: normalize line endings
boesing Jun 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"parser": "@typescript-eslint/parser",
"env": {
"browser": false,
"es2021": true,
"node": true
},
"extends": [
"incredible",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"ecmaVersion": 2021,
"ecmaFeatures": {
"modules": true
}
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"node/no-unpublished-import": ["error", {
"allowModules": ["@cfworker/json-schema"]
}],
"no-process-exit": "off",
"no-sync": "off",
"no-shadow": "off",
"object-curly-spacing": "off",
"comma-dangle": "off",
"censor/no-swear": "off",
"@typescript-eslint/no-inferrable-types": "off",
"object-shorthand": "off"
},
"settings": {
"import/resolver": {
"typescript": {}
}
}
}
37 changes: 34 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on:
pull_request:
push:
branches:
- '[0-9]+.[0-9]+.x'
- 'refs/pull/*'
boesing marked this conversation as resolved.
Show resolved Hide resolved
tags:

env:
TEST_TAG: laminas/ci-matrix-action:test
Expand Down Expand Up @@ -82,7 +84,7 @@ jobs:
id: matrix_generation
env:
PROJECT_NAME_TO_TEST: ${{ matrix.projectName }}
run: cd tests/${PROJECT_NAME_TO_TEST} && docker run -i --entrypoint /action/index.js -v $(realpath .):/github/workspace -w=/github/workspace ${TEST_TAG} $(test -r diff && cat diff || echo -n "")
run: cd tests/${PROJECT_NAME_TO_TEST} && docker run -i --entrypoint "/action/main.js" -v $(realpath .):/github/workspace -w=/github/workspace ${TEST_TAG} $(test -r diff && cat diff || echo -n "")

- name: "Output generated matrix"
uses: sergeysova/jq-action@v2
Expand All @@ -97,5 +99,34 @@ jobs:
with:
cmd: 'jq -c . < tests/${PROJECT_NAME_TO_TEST}/matrix.json'

- name: "verify output of generated matrix for project: empty-project"
run: diff --color <(echo '${{ steps.expected_matrix.outputs.value }}') <(echo '${{ steps.matrix_generation.outputs.matrix }}')
- name: "verify output of generated matrix for project: ${{ matrix.projectName }}"
run: diff --color <(echo '${{ steps.expected_matrix.outputs.value }}' | jq --sort-keys) <(echo '${{ steps.matrix_generation.outputs.matrix }}' | jq --sort-keys)

docker-build:
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build
uses: docker/build-push-action@v2
with:
push: false
boesing marked this conversation as resolved.
Show resolved Hide resolved

linting:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-node@v2"
with:
check-latest: true
- name: "Install node modules"
run: "npm ci"
- name: Run ESLint
run: "npm run lint"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules/
/dist/
24 changes: 16 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
FROM node:current-alpine
FROM node:17-alpine as compiler

RUN mkdir -p /usr/local/source
WORKDIR /usr/local/source
COPY package*.json ./
COPY tsconfig.json ./
COPY webpack.config.js ./
RUN npm ci
COPY ./src ./src
RUN npm run build


FROM node:17-alpine
LABEL "repository"="http://github.com/laminas/laminas-ci-matrix-action"
LABEL "homepage"="http://github.com/laminas/laminas-ci-matrix-action"
LABEL "maintainer"="https://github.com/laminas/technical-steering-committee/"
Expand All @@ -8,14 +19,11 @@ RUN apk update \
&& apk add --no-cache bash git

RUN mkdir /action
ADD index.js /action/index.js
RUN chmod u+x /action/index.js
ADD src /action/src
ADD package.json /action/package.json
ADD package-lock.json /action/package-lock.json
ADD composer.schema.json /action/
ADD https://getcomposer.org/schema.json /action/composer.schema.json
ADD laminas-ci.schema.json /action/
RUN (cd /action ; npm install)

COPY --from=compiler /usr/local/source/dist/main.js /action/
RUN chmod u+x /action/main.js

ADD entrypoint.sh /usr/local/bin/entrypoint.sh

Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,14 @@ $ docker run -v $(realpath .):/github/workspace -w=/github/workspace ghcr.io/lam
```

This will run the action locally and detail what matrix will be produced; it can be particularly useful for debugging issues with your `.laminas-ci.json` configuration.

## Development

In case you want to contribute features, bugfixes, tests or JSONSchema enhancements, you might want to build the docker container locally.

To do so, you can follow these steps:

1. Build the docker container by executing `$ docker build -t laminas/laminas-ci-matrix-action:dev-local .`
2. Change to the `tests/` directory you want to create a matrix for
3. Run the docker container while overriding the `entrypoint.sh` to ensure the `diff` is being passed to the matrix generator
- `docker run -it --entrypoint "/action/main.js" -v $(realpath .):/github/workspace -w=/github/workspace docker.io/laminas/laminas-ci-matrix-action:dev-local $(test -r diff && cat diff || echo "")`
Loading