From 6bdbc486130ccdae7cb3e6afe672f4f10609ac04 Mon Sep 17 00:00:00 2001 From: Frederik Prijck Date: Wed, 8 Nov 2023 12:55:44 +0100 Subject: [PATCH] Add GitHub Actions --- .github/actions/build/build.yml | 47 +++++++++++++++++++++ .github/workflows/build.yml | 74 +++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 .github/actions/build/build.yml create mode 100644 .github/workflows/build.yml diff --git a/.github/actions/build/build.yml b/.github/actions/build/build.yml new file mode 100644 index 00000000..d48589df --- /dev/null +++ b/.github/actions/build/build.yml @@ -0,0 +1,47 @@ +name: Build package +description: Build the SDK package + +inputs: + node: + description: The node version to use + required: false + default: 18 + working_directory: + description: The current working directory + required: true + config_path: + description: The path to the configuration file + required: true + test_cmd: + description: The command to run the tests + required: true + default: npm test + +runs: + using: composite + + steps: + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node }} + cache: 'npm' + + - name: Install dependencies + shell: bash + run: npm ci + + - name: Copy config + shell: bash + run: | + cp ${{ inputs.working_directory }}/${{ inputs.config_path }}/auth.config.ts.example ${{ inputs.working_directory }}/${{ inputs.config_path }}/auth.config.ts + + - name: Build + shell: bash + run: npm run build + working-directory: ${{ inputs.working_directory }} + + - name: Tests + shell: bash + run: ${{ inputs.test_cmd }} + working-directory: ${{ inputs.working_directory }} \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..cbc0ef15 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,74 @@ +name: Unit Tests + +on: + merge_group: + workflow_dispatch: + pull_request: + branches: + - main + push: + branches: + - main + - feat/github-actions + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +env: + NODE_VERSION: 18 + CACHE_KEY: '${{ github.ref }}-${{ github.run_id }}-${{ github.run_attempt }}' + +jobs: + build_angular: + name: Build Angular + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.ref }} + + - name: Build Angular + uses: ./.github/actions/build + with: + node: ${{ env.NODE_VERSION }} + working_directory: angular + config_path: src/app + test_cmd: npm run test:ci + build_react: + name: Build React + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.ref }} + + - name: Build React + uses: ./.github/actions/build + with: + node: ${{ env.NODE_VERSION }} + working_directory: react + config_path: src + build_vue: + name: Build Vue + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.ref }} + + - name: Build React + uses: ./.github/actions/build + with: + node: ${{ env.NODE_VERSION }} + working_directory: vue + config_path: src \ No newline at end of file