diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fb08fa..7e5724d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,9 @@ jobs: - uses: actions/upload-artifact@v4 with: name: action - path: action.yml + path: | + action.yml + measure/ test: name: 'Test: package manager ${{ matrix.package-manager }}' strategy: @@ -31,7 +33,10 @@ jobs: with: repository: gabrielrufino/node-template - uses: actions/download-artifact@v4 - - uses: ./action/ + with: + name: action + path: . + - uses: ./ with: package-manager: ${{ matrix.package-manager }} test-using-except: @@ -44,7 +49,10 @@ jobs: with: repository: gabrielrufino/node-template - uses: actions/download-artifact@v4 - - uses: ./action/ + with: + name: action + path: . + - uses: ./ with: except: build test-in-different-operating-systems: @@ -60,7 +68,10 @@ jobs: with: repository: gabrielrufino/node-template - uses: actions/download-artifact@v4 - - uses: ./action/ + with: + name: action + path: . + - uses: ./ concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/action.yml b/action.yml index 4e0b4fa..b4d286b 100644 --- a/action.yml +++ b/action.yml @@ -67,32 +67,24 @@ runs: echo "scripts=$scripts" >> $GITHUB_OUTPUT shell: bash - id: install - run: | - start=$(date +%s) - ${{ steps.package-manager.outputs.install_cmd }} - echo "duration=$(( $(date +%s) - start ))" >> $GITHUB_OUTPUT - shell: bash + uses: ./measure + with: + run: ${{ steps.package-manager.outputs.install_cmd }} - id: build if: ${{ contains(steps.scripts.outputs.scripts, 'build') && !contains(inputs.except, 'build') }} - run: | - start=$(date +%s) - ${{ steps.package-manager.outputs.pkg_cmd }} run build - echo "duration=$(( $(date +%s) - start ))" >> $GITHUB_OUTPUT - shell: bash + uses: ./measure + with: + run: ${{ steps.package-manager.outputs.pkg_cmd }} run build - id: lint if: ${{ contains(steps.scripts.outputs.scripts, 'lint') && !contains(inputs.except, 'lint') }} - run: | - start=$(date +%s) - ${{ steps.package-manager.outputs.pkg_cmd }} run lint - echo "duration=$(( $(date +%s) - start ))" >> $GITHUB_OUTPUT - shell: bash + uses: ./measure + with: + run: ${{ steps.package-manager.outputs.pkg_cmd }} run lint - id: test if: ${{ contains(steps.scripts.outputs.scripts, 'test') && !contains(inputs.except, 'test') }} - run: | - start=$(date +%s) - ${{ steps.package-manager.outputs.pkg_cmd }} test - echo "duration=$(( $(date +%s) - start ))" >> $GITHUB_OUTPUT - shell: bash + uses: ./measure + with: + run: ${{ steps.package-manager.outputs.pkg_cmd }} test - run: ${{ steps.package-manager.outputs.pkg_cmd }} run test:e2e if: ${{ contains(steps.scripts.outputs.scripts, 'test:e2e') && !contains(inputs.except, 'test:e2e') }} shell: bash diff --git a/measure/action.yml b/measure/action.yml new file mode 100644 index 0000000..3e5b87e --- /dev/null +++ b/measure/action.yml @@ -0,0 +1,19 @@ +name: 'Measure' +description: 'Runs a command and measures its duration' +inputs: + run: + required: true + description: 'The command to run' +outputs: + duration: + description: 'Duration of the command in seconds' + value: ${{ steps.run.outputs.duration }} +runs: + using: composite + steps: + - id: run + run: | + start=$(date +%s) + ${{ inputs.run }} + echo "duration=$(( $(date +%s) - start ))" >> $GITHUB_OUTPUT + shell: bash