From 85e70268402826b07000f0c0d5e308667a194ef1 Mon Sep 17 00:00:00 2001 From: Harmen Wessels <97173058+harmen-xb@users.noreply.github.com> Date: Wed, 25 Oct 2023 21:34:39 +0200 Subject: [PATCH] Refactored workflows from actions to subworkflow. --- .github/actions/build/action.yml | 30 ------- .../actions/publish-test-results/action.yml | 20 ----- .github/actions/test/action.yml | 21 ----- .github/workflows/build-and-test.yml | 88 +++++++++++++++++++ .github/workflows/cicd-feature.yml | 13 +++ .github/workflows/cicd-main.yml | 10 +++ .github/workflows/feature.yml | 42 --------- .github/workflows/main.yml | 39 -------- 8 files changed, 111 insertions(+), 152 deletions(-) delete mode 100644 .github/actions/build/action.yml delete mode 100644 .github/actions/publish-test-results/action.yml delete mode 100644 .github/actions/test/action.yml create mode 100644 .github/workflows/build-and-test.yml create mode 100644 .github/workflows/cicd-feature.yml create mode 100644 .github/workflows/cicd-main.yml delete mode 100644 .github/workflows/feature.yml delete mode 100644 .github/workflows/main.yml diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml deleted file mode 100644 index ccb1dca5..00000000 --- a/.github/actions/build/action.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: build -description: 'Build CrossModel' -inputs: - node-version: - description: 'Node version to use' - required: true - default: '16.20.0' - python-version: - description: 'Python version to use' - required: true - default: '3.11.4' - -runs: - using: 'composite' - steps: - - name: Setup Node.js ${{ inputs.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ inputs.node-version }} - - - name: Setup Python ${{ inputs.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ inputs.python-version }} - - - name: Yarn build - shell: bash - run: | - yarn --skip-integrity-check --network-timeout 100000 - yarn build diff --git a/.github/actions/publish-test-results/action.yml b/.github/actions/publish-test-results/action.yml deleted file mode 100644 index 55232557..00000000 --- a/.github/actions/publish-test-results/action.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: publish-test-report -description: 'Publish Test Report' - -runs: # windows-2019 # is needed because the Setup Python task does not work with ubuntu - using: 'composite' - steps: - # Download the test results artifacts. - - name: Download Test Results - uses: actions/download-artifact@v3 - with: - name: unit-test-tesults - path: unit-test-tesults - - # Publish Test Results - - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - check_name: Test Results - files: | - unit-test-tesults/*.xml diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml deleted file mode 100644 index e8e90040..00000000 --- a/.github/actions/test/action.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: test -description: 'Test CrossModel' - -runs: # windows-2019 # is needed because the Setup Python task does not work with ubuntu - using: 'composite' - steps: - - name: Yarn test - shell: bash - run: yarn test - env: - # The test result file name can be controlled using the following environment variable. - JEST_JUNIT_OUTPUT_NAME: test-results-${{ runner.os }}.xml - - # Upload Test Results (The different files for the OSes will end up in the same artifact). - - name: Upload Test Results - if: always() - uses: actions/upload-artifact@v3 - with: - name: unit-test-tesults - path: | - **/test-results-${{ runner.os }}.xml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 00000000..992b508b --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,88 @@ +on: + workflow_call: + inputs: + node-version: + description: 'Node version to use' + required: true + default: '16.20.0' + python-version: + description: 'Python version to use' + required: true + default: '3.11.4' + +defaults: + run: + shell: bash + +jobs: + build-and-test: + name: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [windows-2019, ubuntu-latest, macos-11] + + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + + steps: + # Checkout the code. + - name: checkout + uses: actions/checkout@v4 + + # Setup Node + - name: Setup Node.js ${{ inputs.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + + # Setup Python + - name: Setup Python ${{ inputs.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ inputs.python-version }} + + # Build the code. + - name: Yarn build + # We set a timeout here as a fix for the timeout issues which sometimes occur when connecting the the npm repo. + run: | + yarn --skip-integrity-check --network-timeout 100000 + yarn build + + # Execute the tests. + - name: Yarn test + run: yarn test + env: + # The test result file name can be controlled using the following environment variable. + JEST_JUNIT_OUTPUT_NAME: test-results-${{ runner.os }}.xml + + # Upload Test Results (The different files for the OSes will end up in the same artifact). + - name: Upload Test Results + if: always() + uses: actions/upload-artifact@v3 + with: + name: unit-test-tesults + path: | + **/test-results-${{ runner.os }}.xml + + # Publish a test report using the test result files published in the previous step (executed per OS). + publish-test-report: + name: Publish Test Report + needs: build-and-test + runs-on: ubuntu-latest + if: always() + steps: + # Download the test results artifacts. + - name: Download Test Results + uses: actions/download-artifact@v3 + with: + name: unit-test-tesults + path: unit-test-tesults + # Publish Test Results + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + check_name: Test Results + files: | + unit-test-tesults/*.xml diff --git a/.github/workflows/cicd-feature.yml b/.github/workflows/cicd-feature.yml new file mode 100644 index 00000000..3c9200ac --- /dev/null +++ b/.github/workflows/cicd-feature.yml @@ -0,0 +1,13 @@ +name: cicd-feature + +on: + push: + branches: + - feature/* + pull_request: + branches: + - feature/* + +jobs: + build-and-test: + uses: ./.github/workflows/build-and-test.yml diff --git a/.github/workflows/cicd-main.yml b/.github/workflows/cicd-main.yml new file mode 100644 index 00000000..46fdcd93 --- /dev/null +++ b/.github/workflows/cicd-main.yml @@ -0,0 +1,10 @@ +name: cicd-main + +on: + push: + branches: + - main + +jobs: + build-and-test: + uses: ./.github/workflows/build-and-test.yml diff --git a/.github/workflows/feature.yml b/.github/workflows/feature.yml deleted file mode 100644 index a9655c5f..00000000 --- a/.github/workflows/feature.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: feature - -on: - push: - branches: - - feature/* - pull_request: - branches: - - feature/* - -jobs: - build-and-test: - name: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: [windows-2019, ubuntu-latest, macos-11] - - runs-on: ${{ matrix.os }} - timeout-minutes: 60 - - steps: - # Checkout the code. - - name: checkout # is needed to read the files on the root folder of the repo - uses: actions/checkout@v4 - # Use the build action. - - uses: ./.github/actions/build - # Use the test action. - - uses: ./.github/actions/test - - publish-test-report: - name: Publish Test Report - needs: build-and-test - runs-on: ubuntu-latest - if: always() - steps: - # Checkout the code (needed for the action). - - name: checkout # is needed to read the files on the root folder of the repo - uses: actions/checkout@v4 - # Use the publish-test-report action. - - uses: ./.github/actions/publish-test-report diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 7df24152..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: main - -on: - push: - branches: - - main - -jobs: - build-and-test: - name: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: [windows-2019, ubuntu-latest, macos-11] - - runs-on: ${{ matrix.os }} - timeout-minutes: 60 - - steps: - # Checkout the code. - - name: checkout # is needed to read the files on the root folder of the repo - uses: actions/checkout@v4 - # Use the build action. - - uses: ./.github/actions/build - # Use the test action. - - uses: ./.github/actions/test - - publish-test-report: - name: Publish Test Report - needs: build-and-test - runs-on: ubuntu-latest - if: always() - steps: - # Checkout the code (needed for the action). - - name: checkout # is needed to read the files on the root folder of the repo - uses: actions/checkout@v4 - # Use the publish-test-report action. - - uses: ./.github/actions/publish-test-report