iT邦幫忙

2021 iThome 鐵人賽

DAY 10
1

CI 持續整合。

為什麼要 CI 呢?
想想我們前面寫了那麼辛苦的自動測試,結果有人不跑測試就上傳。
這時候就需要為我們的 workflow 來個測試守門員,通過測試才可以整合。

Hello Workflow

1.new Actions
Actions 在專案的導覽列可以找到

2.new workflow
選 setup yourself
https://ithelp.ithome.com.tw/upload/images/20210925/20139745ou49vpLvak.png

3.new main.yml
commit template
https://ithelp.ithome.com.tw/upload/images/20210925/20139745kveiFUsJnR.png

4.搭拉
echo Hello World
https://ithelp.ithome.com.tw/upload/images/20210925/20139745ejWajiC6cB.png

修改 Workflow

範本建立成功後,接下來最重要的就是找到一份合適的 yml 貼進 action workflow...

來源

# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  tests:
    name: Run tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1

      - name: Cache composer dependencies
        uses: actions/cache@v1
        with:
          path: vendor
          key: composer-${{ hashFiles('composer.lock') }}

      - name: Run composer install
        run: composer install -n --prefer-dist
        env:
          APP_ENV: testing

      - name: Prepare Laravel Application
        run: |
          cp .env.example .env
          php artisan key:generate
      - name: Cache yarn dependencies
        uses: actions/cache@v1
        with:
          path: node_modules
          key: yarn-${{ hashFiles('yarn.lock') }}

      - name: Run yarn
        run: yarn && yarn dev

      - name: Run tests
        run: ./vendor/bin/phpunit
        env:
          APP_ENV: testing

      - name: Upload artifacts
        uses: actions/upload-artifact@master
        if: failure()
        with:
          name: Logs
          path: ./storage/logs

https://ithelp.ithome.com.tw/upload/images/20210925/20139745pqwjOR9kCB.png

怎麼今天的文章好像又不太連貫?
是舊文,我又貼了舊文。


上一篇
09. E2E Test x Browser Test x Cypress
下一篇
11. Bug x Debug x Debug Tool
系列文
每天一篇文章30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言