CI 持續整合。
為什麼要 CI 呢?
想想我們前面寫了那麼辛苦的自動測試,結果有人不跑測試就上傳。
這時候就需要為我們的 workflow 來個測試守門員,通過測試才可以整合。
1.new Actions
Actions 在專案的導覽列可以找到
2.new workflow
選 setup yourself
3.new main.yml
commit template
4.搭拉
echo Hello World
範本建立成功後,接下來最重要的就是找到一份合適的 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
怎麼今天的文章好像又不太連貫?
是舊文,我又貼了舊文。