diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 000000000..9e8971808 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,21 @@ +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 + run: npm ci + + - name: Build + 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..85b01763e --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,21 @@ +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 + run: npm ci + + - name: Linting + 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..5a5f504be --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,21 @@ +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 + run: npm ci + + - name: Unit tests + 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 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/client.yaml b/config/config_files/workflows/check_config.yaml similarity index 62% rename from config/config_files/client.yaml rename to config/config_files/workflows/check_config.yaml index 0f95e327e..b3ac2db5f 100644 --- a/config/config_files/client.yaml +++ b/config/config_files/workflows/check_config.yaml @@ -1,82 +1,7 @@ -name: Client actions - +name: Check Config files on: - pull_request: - branches: [main, master, develop, development, staging] - paths: - - 'client/**' - - '.github/workflows/client.yaml' - + 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 - - 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 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