|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: main-linklite-${{ github.event.number }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + tests: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + name: Server |
| 19 | + |
| 20 | + services: |
| 21 | + redis-cache: |
| 22 | + image: redis:alpine |
| 23 | + ports: |
| 24 | + - 13000:6379 |
| 25 | + redis-queue: |
| 26 | + image: redis:alpine |
| 27 | + ports: |
| 28 | + - 11000:6379 |
| 29 | + mariadb: |
| 30 | + image: mariadb:10.6 |
| 31 | + env: |
| 32 | + MYSQL_ROOT_PASSWORD: root |
| 33 | + ports: |
| 34 | + - 3306:3306 |
| 35 | + options: --health-cmd="mariadb-admin ping" --health-interval=5s --health-timeout=2s --health-retries=3 |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Clone |
| 39 | + uses: actions/checkout@v3 |
| 40 | + |
| 41 | + - name: Find tests |
| 42 | + run: | |
| 43 | + echo "Finding tests" |
| 44 | + grep -rn "def test" > /dev/null |
| 45 | +
|
| 46 | + - name: Setup Python |
| 47 | + uses: actions/setup-python@v4 |
| 48 | + with: |
| 49 | + python-version: '3.10' |
| 50 | + |
| 51 | + - name: Setup Node |
| 52 | + uses: actions/setup-node@v3 |
| 53 | + with: |
| 54 | + node-version: 18 |
| 55 | + check-latest: true |
| 56 | + |
| 57 | + - name: Cache pip |
| 58 | + uses: actions/cache@v2 |
| 59 | + with: |
| 60 | + path: ~/.cache/pip |
| 61 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py', '**/setup.cfg') }} |
| 62 | + restore-keys: | |
| 63 | + ${{ runner.os }}-pip- |
| 64 | + ${{ runner.os }}- |
| 65 | +
|
| 66 | + - name: Get yarn cache directory path |
| 67 | + id: yarn-cache-dir-path |
| 68 | + run: 'echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT' |
| 69 | + |
| 70 | + - uses: actions/cache@v3 |
| 71 | + id: yarn-cache |
| 72 | + with: |
| 73 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 74 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 75 | + restore-keys: | |
| 76 | + ${{ runner.os }}-yarn- |
| 77 | +
|
| 78 | + - name: Install MariaDB Client |
| 79 | + run: | |
| 80 | + sudo apt update |
| 81 | + sudo apt-get install mariadb-client-10.6 |
| 82 | +
|
| 83 | + - name: Setup |
| 84 | + run: | |
| 85 | + pip install frappe-bench |
| 86 | + bench init --skip-redis-config-generation --skip-assets --python "$(which python)" ~/frappe-bench |
| 87 | + mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'" |
| 88 | + mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" |
| 89 | +
|
| 90 | + - name: Install |
| 91 | + working-directory: /home/runner/frappe-bench |
| 92 | + run: | |
| 93 | + bench get-app linklite $GITHUB_WORKSPACE |
| 94 | + bench setup requirements --dev |
| 95 | + bench new-site --db-root-password root --admin-password admin test_site |
| 96 | + bench --site test_site install-app linklite |
| 97 | + bench build |
| 98 | + env: |
| 99 | + CI: 'Yes' |
| 100 | + |
| 101 | + - name: Run Tests |
| 102 | + working-directory: /home/runner/frappe-bench |
| 103 | + run: | |
| 104 | + bench --site test_site set-config allow_tests true |
| 105 | + bench --site test_site run-tests --app linklite |
| 106 | + env: |
| 107 | + TYPE: server |
0 commit comments