From 862eb3f5497a4afac368e019eea5193e22fd5f35 Mon Sep 17 00:00:00 2001 From: Brynjulf Risbakken Date: Wed, 31 Jan 2024 11:31:10 +0100 Subject: [PATCH 1/4] :construction_worker: :art: split workflows into multiple files --- config/config_files/workflows/build.yaml | 23 ++++++++ .../config_files/workflows/build_docker.yaml | 12 +++++ .../config_files/workflows/check_config.yaml | 53 +++++++++++++++++++ config/config_files/workflows/lint.yaml | 23 ++++++++ .../config_files/workflows/pull_request.yaml | 29 ++++++++++ config/config_files/workflows/test.yaml | 23 ++++++++ config/github_actions_list.txt | 6 +++ config/install.sh | 10 +++- 8 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 config/config_files/workflows/build.yaml create mode 100644 config/config_files/workflows/build_docker.yaml create mode 100644 config/config_files/workflows/check_config.yaml create mode 100644 config/config_files/workflows/lint.yaml create mode 100644 config/config_files/workflows/pull_request.yaml create mode 100644 config/config_files/workflows/test.yaml create mode 100644 config/github_actions_list.txt diff --git a/config/config_files/workflows/build.yaml b/config/config_files/workflows/build.yaml new file mode 100644 index 000000000..8896e5807 --- /dev/null +++ b/config/config_files/workflows/build.yaml @@ -0,0 +1,23 @@ +name: Build +on: + workflow_call: +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + + - name: Install dependencies + working-directory: client + run: npm ci + + - name: Build + working-directory: client + run: npm run build diff --git a/config/config_files/workflows/build_docker.yaml b/config/config_files/workflows/build_docker.yaml new file mode 100644 index 000000000..24aad1856 --- /dev/null +++ b/config/config_files/workflows/build_docker.yaml @@ -0,0 +1,12 @@ +name: Build docker image +on: + workflow_call: +jobs: + build-docker: + name: Build client docker image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build the docker image + working-directory: client + run: docker build . --file Dockerfile diff --git a/config/config_files/workflows/check_config.yaml b/config/config_files/workflows/check_config.yaml new file mode 100644 index 000000000..b3ac2db5f --- /dev/null +++ b/config/config_files/workflows/check_config.yaml @@ -0,0 +1,53 @@ +name: Check Config files +on: + workflow_call: +jobs: + check_configs: + name: Compare local to remote config files + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Compare remote .eslintrc.js to local + working-directory: client + run: diff .eslintrc.js <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/.eslintrc.js) + + - name: Compare remote .prettierrc.js to local + working-directory: client + run: diff .prettierrc.js <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/.prettierrc.js) + + - name: Compare remote .prettierignore to local + working-directory: client + run: diff .prettierignore <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/.prettierignore) + + - name: Compare remote tsconfig.json to local + working-directory: client + run: diff tsconfig.json <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/tsconfig.json) + + - name: Compare remote Dockerfile to local + working-directory: client + run: diff Dockerfile <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/Dockerfile) + + - name: Compare remote env.sh to local + working-directory: client + run: diff env.sh <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/env.sh) + + - name: Compare remote vite.config.ts to local + working-directory: client + run: diff vite.config.ts <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/vite.config.ts) + + - name: Compare remote proxy/nginx.conf to local + working-directory: client/proxy + run: diff nginx.conf <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/nginx.conf) + + - name: Compare remote proxy/securityheaders.conf to local + working-directory: client/proxy + run: diff securityheaders.conf <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/securityheaders.conf) + + - name: Compare remote src/setupLocalhost.mjs to local + working-directory: client/src + run: diff setupLocalhost.mjs <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/setupLocalhost.mjs) + + - name: Compare remote src/setupTests.ts to local + working-directory: client/src + run: diff setupTests.ts <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/setupTests.ts) diff --git a/config/config_files/workflows/lint.yaml b/config/config_files/workflows/lint.yaml new file mode 100644 index 000000000..70ad3ad70 --- /dev/null +++ b/config/config_files/workflows/lint.yaml @@ -0,0 +1,23 @@ +name: Lint +on: + workflow_call: +jobs: + lint: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + + - name: Install dependencies + working-directory: client + run: npm ci + + - name: Linting + working-directory: client + run: npm run lint diff --git a/config/config_files/workflows/pull_request.yaml b/config/config_files/workflows/pull_request.yaml new file mode 100644 index 000000000..61df1b4e4 --- /dev/null +++ b/config/config_files/workflows/pull_request.yaml @@ -0,0 +1,29 @@ +name: Pull request + +on: + pull_request: + branches: [main, master, develop, development, staging] + paths: + - "client/**" + - ".github/workflows/**" + workflow_dispatch: +jobs: + lint: + name: Lint + uses: ./.github/workflows/lint.yaml + + test: + name: Test + uses: ./.github/workflows/test.yaml + + build: + name: Build + uses: ./.github/workflows/build.yaml + + build-docker: + name: Build docker image + uses: ./.github/workflows/build_docker.yaml + + check_configs: + name: Check Config files + uses: ./.github/workflows/check_config.yaml diff --git a/config/config_files/workflows/test.yaml b/config/config_files/workflows/test.yaml new file mode 100644 index 000000000..e78069800 --- /dev/null +++ b/config/config_files/workflows/test.yaml @@ -0,0 +1,23 @@ +name: Test +on: + workflow_call: +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + + - name: Install dependencies + working-directory: client + run: npm ci + + - name: Unit tests + working-directory: client + run: npm run test:ci --passWithNoTests diff --git a/config/github_actions_list.txt b/config/github_actions_list.txt new file mode 100644 index 000000000..8d893eb15 --- /dev/null +++ b/config/github_actions_list.txt @@ -0,0 +1,6 @@ +https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/workflows/build_docker.yaml +https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/workflows/build.yaml +https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/workflows/test.yaml +https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/workflows/lint.yaml +https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/workflows/check_config.yaml +https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/workflows/pull_request.yaml diff --git a/config/install.sh b/config/install.sh index 9aa5e0f73..b4025c79f 100644 --- a/config/install.sh +++ b/config/install.sh @@ -45,8 +45,14 @@ curl -s "https://raw.githubusercontent.com/equinor/amplify-components/main/confi cd ../.. -printf -- "Downloading client github action...\n" -curl -s "https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/client.yaml" > .github/workflows/client.yaml +printf -- "Downloading client github actions...\n" +workflowsList=$(curl -s "https://raw.githubusercontent.com/equinor/amplify-components/main/config/github_actions_list.txt") + +for line in $workflowsList +do + fileName=$(echo $line | rev | cut -d '/' -f 1 | rev) + curl -s $line > "./github/workflows/$fileName" +done printf -- "Downloading CODEOWNERS file...\n" curl -s "https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/CODEOWNERS" > .github/CODEOWNERS \ No newline at end of file From 43e9c782791ba61d8171454d544d39706da47b97 Mon Sep 17 00:00:00 2001 From: Brynjulf Risbakken Date: Wed, 31 Jan 2024 11:41:56 +0100 Subject: [PATCH 2/4] :construction_worker: :art: split workflows into multiple files in amplify-components --- .github/workflows/build.yaml | 23 ++++++ .github/workflows/build_storybook.yaml | 21 ++++++ .github/workflows/code_coverage.yaml | 21 ++++++ .github/workflows/lint.yaml | 23 ++++++ .github/workflows/pr_actions.yaml | 100 ------------------------- .github/workflows/pull_request.yaml | 29 +++++++ .github/workflows/test.yaml | 23 ++++++ 7 files changed, 140 insertions(+), 100 deletions(-) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/build_storybook.yaml create mode 100644 .github/workflows/code_coverage.yaml create mode 100644 .github/workflows/lint.yaml delete mode 100644 .github/workflows/pr_actions.yaml create mode 100644 .github/workflows/pull_request.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 000000000..8896e5807 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,23 @@ +name: Build +on: + workflow_call: +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + + - name: Install dependencies + working-directory: client + run: npm ci + + - name: Build + working-directory: client + run: npm run build diff --git a/.github/workflows/build_storybook.yaml b/.github/workflows/build_storybook.yaml new file mode 100644 index 000000000..31641a28f --- /dev/null +++ b/.github/workflows/build_storybook.yaml @@ -0,0 +1,21 @@ +name: Build storybook +on: + workflow_call: +jobs: + build-storybook: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build-storybook diff --git a/.github/workflows/code_coverage.yaml b/.github/workflows/code_coverage.yaml new file mode 100644 index 000000000..8ba7a8a7e --- /dev/null +++ b/.github/workflows/code_coverage.yaml @@ -0,0 +1,21 @@ +name: Test +on: + workflow_call: +jobs: + code-coverage: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + + - name: Install dependencies + run: npm ci + + - name: Unit tests + run: npm run test:coverage diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 000000000..70ad3ad70 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,23 @@ +name: Lint +on: + workflow_call: +jobs: + lint: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + + - name: Install dependencies + working-directory: client + run: npm ci + + - name: Linting + working-directory: client + run: npm run lint diff --git a/.github/workflows/pr_actions.yaml b/.github/workflows/pr_actions.yaml deleted file mode 100644 index 045e54778..000000000 --- a/.github/workflows/pr_actions.yaml +++ /dev/null @@ -1,100 +0,0 @@ -name: PR actions - -on: - pull_request: - branches: [main] - paths: - - '**' - - '.github/workflows/client.yml' - -jobs: - lint: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [20.x] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - - - name: Install dependencies - run: npm ci - - - name: Linting - run: npm run lint - - test: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [20.x] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - - - name: Install dependencies - run: npm ci - - - name: Unit tests - run: npm run test:ci - - code-coverage: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [20.x] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - - - name: Install dependencies - run: npm ci - - - name: Unit tests - run: npm run test:coverage - - build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [20.x] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - - - run: corepack enable - - name: Install dependencies - run: npm ci - - - name: Build - run: npm run build - - build-storybook: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [20.x] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - - - name: Install dependencies - run: npm ci - - - name: Build - run: npm run build-storybook diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml new file mode 100644 index 000000000..4da7a173a --- /dev/null +++ b/.github/workflows/pull_request.yaml @@ -0,0 +1,29 @@ +name: Pull request + +on: + pull_request: + branches: [main] + paths: + - "**" + - ".github/workflows/**" + workflow_dispatch: +jobs: + lint: + name: Lint + uses: ./.github/workflows/lint.yaml + + test: + name: Test + uses: ./.github/workflows/test.yaml + + code-coverage: + name: Code coverage + uses: ./.github/workflows/code_coverage.yaml + + build: + name: Build + uses: ./.github/workflows/build.yaml + + build-storybook: + name: Build storybook + uses: ./.github/workflows/build_storybook.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 000000000..445d6c0ea --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,23 @@ +name: Test +on: + workflow_call: +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + + - name: Install dependencies + working-directory: client + run: npm ci + + - name: Unit tests + working-directory: client + run: npm run test:ci From 125bdb54d3c01fb4da0d32ed8809b051ae1cc416 Mon Sep 17 00:00:00 2001 From: Brynjulf Risbakken Date: Wed, 31 Jan 2024 11:43:08 +0100 Subject: [PATCH 3/4] :fire: removed old actions file --- config/config_files/client.yaml | 128 -------------------------------- 1 file changed, 128 deletions(-) delete mode 100644 config/config_files/client.yaml diff --git a/config/config_files/client.yaml b/config/config_files/client.yaml deleted file mode 100644 index 0f95e327e..000000000 --- a/config/config_files/client.yaml +++ /dev/null @@ -1,128 +0,0 @@ -name: Client actions - -on: - pull_request: - branches: [main, master, develop, development, staging] - paths: - - 'client/**' - - '.github/workflows/client.yaml' - -jobs: - lint: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [20.x] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - - - name: Install dependencies - working-directory: client - run: npm ci - - - name: Linting - working-directory: client - run: npm run lint - - test: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [20.x] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - - - name: Install dependencies - working-directory: client - run: npm ci - - - name: Unit tests - working-directory: client - run: npm run test:ci --passWithNoTests - - build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [20.x] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - - - name: Install dependencies - working-directory: client - run: npm ci - - - name: Build - working-directory: client - run: npm run build - - build-docker: - name: Build client docker image - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Build the docker image - working-directory: client - run: docker build . --file Dockerfile - - check_configs: - name: Compare local to remote config files - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Compare remote .eslintrc.js to local - working-directory: client - run: diff .eslintrc.js <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/.eslintrc.js) - - - name: Compare remote .prettierrc.js to local - working-directory: client - run: diff .prettierrc.js <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/.prettierrc.js) - - - name: Compare remote .prettierignore to local - working-directory: client - run: diff .prettierignore <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/.prettierignore) - - - name: Compare remote tsconfig.json to local - working-directory: client - run: diff tsconfig.json <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/tsconfig.json) - - - name: Compare remote Dockerfile to local - working-directory: client - run: diff Dockerfile <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/Dockerfile) - - - name: Compare remote env.sh to local - working-directory: client - run: diff env.sh <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/env.sh) - - - name: Compare remote vite.config.ts to local - working-directory: client - run: diff vite.config.ts <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/vite.config.ts) - - - name: Compare remote proxy/nginx.conf to local - working-directory: client/proxy - run: diff nginx.conf <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/nginx.conf) - - - name: Compare remote proxy/securityheaders.conf to local - working-directory: client/proxy - run: diff securityheaders.conf <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/securityheaders.conf) - - - name: Compare remote src/setupLocalhost.mjs to local - working-directory: client/src - run: diff setupLocalhost.mjs <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/setupLocalhost.mjs) - - - name: Compare remote src/setupTests.ts to local - working-directory: client/src - run: diff setupTests.ts <(curl https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/setupTests.ts) From d1f2143dc7c4e7069701755273596be3be6686b8 Mon Sep 17 00:00:00 2001 From: Brynjulf Risbakken Date: Wed, 31 Jan 2024 11:44:05 +0100 Subject: [PATCH 4/4] :memo: update read to reflect that we download multiple workflow files --- .github/workflows/build.yaml | 2 -- .github/workflows/lint.yaml | 2 -- .github/workflows/test.yaml | 2 -- README.md | 2 +- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8896e5807..9e8971808 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,9 +15,7 @@ jobs: uses: actions/setup-node@v3 - name: Install dependencies - working-directory: client run: npm ci - name: Build - working-directory: client run: npm run build diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 70ad3ad70..85b01763e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -15,9 +15,7 @@ jobs: uses: actions/setup-node@v3 - name: Install dependencies - working-directory: client run: npm ci - name: Linting - working-directory: client run: npm run lint diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 445d6c0ea..5a5f504be 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,9 +15,7 @@ jobs: uses: actions/setup-node@v3 - name: Install dependencies - working-directory: client run: npm ci - name: Unit tests - working-directory: client run: npm run test:ci diff --git a/README.md b/README.md index 41aa5011d..f94fac25b 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ wget -q -O - https://raw.githubusercontent.com/equinor/amplify-components/main/c ``` -This should have downloaded the `.eslintrc.cjs`, `.prettierignore`, `.prettierrc.jr`, `tsconfig.json`, `env.sh`, `Dockerfile`, `proxy/nginx.conf`, `proxy/securityheaders.conf` and `client.yaml` files +This should have downloaded the `.eslintrc.cjs`, `.prettierignore`, `.prettierrc.jr`, `tsconfig.json`, `env.sh`, `Dockerfile`, `proxy/nginx.conf`, `proxy/securityheaders.conf` and github actions workflow files ## Notes