From 4ada3334c565912e27d5f02be5e857f277ba406a Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Thu, 30 Nov 2023 21:19:50 +0100 Subject: [PATCH] Refactor workflow action to enable pull request workflow --- .github/actions/checkout-install-build.yml | 42 +++++++++++++++++++ .github/workflows/pull_request.yml | 16 +++++++ .../workflows/{workflow.yml => tagging.yml} | 39 +---------------- 3 files changed, 60 insertions(+), 37 deletions(-) create mode 100644 .github/actions/checkout-install-build.yml create mode 100644 .github/workflows/pull_request.yml rename .github/workflows/{workflow.yml => tagging.yml} (62%) diff --git a/.github/actions/checkout-install-build.yml b/.github/actions/checkout-install-build.yml new file mode 100644 index 0000000..39bfa41 --- /dev/null +++ b/.github/actions/checkout-install-build.yml @@ -0,0 +1,42 @@ +name: "Checkout, install and build" +description: "Checkout, install and build" + +runs: + using: "composite" + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: actions/setup-node@v4 + with: + node-version: lts/* + cache: yarn + cache-dependency-path: '**/yarn.lock' + - uses: actions/cache@v3 + with: + path: | + ~/.cache/pip + ~/.platformio/.cache + ~/data/node_modules + key: ${{ runner.os }}-pio + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + - name: Get current date + id: dateAndTime + run: echo "dateAndTime=$(date +'%Y-%m-%d-%H:%M')" >> $GITHUB_OUTPUT + - name: Install PlatformIO Core + run: pip install --upgrade platformio + - name: Run unit tests + run: mkdir -p junit-reports && pio test -e native_test_only --junit-output-path junit-reports/ + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: success() || failure() # always run even if the previous step fails + with: + report_paths: '**/junit-reports/*.xml' + detailed_summary: true + - name: Build BTClock firmware + run: pio run -e lolin_s3_mini_qr + + - name: Build BTClock filesystem + run: pio run -e lolin_s3_mini_qr --target buildfs \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..e707003 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,16 @@ +name: Pull Request Workflow + +on: + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + checks: write + steps: + - name: "Checkout, install and build" + uses: ./.github/actions/checkout-install-build \ No newline at end of file diff --git a/.github/workflows/workflow.yml b/.github/workflows/tagging.yml similarity index 62% rename from .github/workflows/workflow.yml rename to .github/workflows/tagging.yml index 183aa24..5ac9a7e 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/tagging.yml @@ -12,43 +12,8 @@ jobs: contents: write checks: write steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: actions/setup-node@v4 - with: - node-version: lts/* - cache: yarn - cache-dependency-path: '**/yarn.lock' - - uses: actions/cache@v3 - with: - path: | - ~/.cache/pip - ~/.platformio/.cache - ~/data/node_modules - key: ${{ runner.os }}-pio - - uses: actions/setup-python@v4 - with: - python-version: '3.9' - - name: Get current date - id: dateAndTime - # run: echo "::set-output name=dateAndTime::$(date +'%Y-%m-%d-%H:%M')" - run: echo "dateAndTime=$(date +'%Y-%m-%d-%H:%M')" >> $GITHUB_OUTPUT - - name: Install PlatformIO Core - run: pip install --upgrade platformio - - name: Run unit tests - run: mkdir -p junit-reports && pio test -e native_test_only --junit-output-path junit-reports/ - - name: Publish Test Report - uses: mikepenz/action-junit-report@v4 - if: success() || failure() # always run even if the previous step fails - with: - report_paths: '**/junit-reports/*.xml' - detailed_summary: true - - name: Build BTClock firmware - run: pio run -e lolin_s3_mini_qr - - - name: Build BTClock filesystem - run: pio run -e lolin_s3_mini_qr --target buildfs + - name: "Checkout, install and build" + uses: ./.github/actions/checkout-install-build - name: Install esptools.py run: pip install --upgrade esptool