-
Notifications
You must be signed in to change notification settings - Fork 25
110 lines (92 loc) · 3.32 KB
/
test_generated_app.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Test Generated App
on: push
env:
COMPOSE_FILE: docker-compose.test.yml
APP_NAME: rails-templates
DOCKER_IMAGE: ${{ github.repository }}
DOCKER_REGISTRY_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }}
DOCKER_REGISTRY_USERNAME: ${{ github.repository_owner }}
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
RUBY_VERSION: 3.3.1
NODE_VERSION: 22
RAILS_VERSION: 7.1.3
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: ${{ matrix.variant }} variant
runs-on: ubuntu-latest
strategy:
matrix:
variant: [web, api]
steps:
- uses: actions/checkout@v3
- name: Set env BRANCH_TAG
uses: nimblehq/branch-tag-action@1
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache gems
uses: actions/cache@v3
with:
path: /home/runner/.rubies/ruby-${{ env.RUBY_VERSION }}
key: ${{ runner.os }}-gems-${{ env.RUBY_VERSION }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-${{ env.RUBY_VERSION }}-
- name: Create app folder
run: mkdir $APP_NAME
- name: Get yarn cache directory path
if: ${{ matrix.variant == 'web' }}
id: yarn-cache-dir-path
run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache npm packages
if: ${{ matrix.variant == 'web' }}
uses: actions/cache@v3
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.yarn_cache_dir }}
**/yarn.lock
**/node_modules
key: ${{ runner.os }}-npm-packages-${{ hashFiles('**/package.json*') }}
restore-keys: |
${{ runner.os }}-npm-packages-
- name: Create rails app
run: |
gem install rails -v ${{ env.RAILS_VERSION }} --no-document
make create_${{ matrix.variant }}
- name: Login to docker registry
uses: docker/login-action@v2
with:
registry: ${{ env.DOCKER_REGISTRY_HOST }}
username: ${{ env.DOCKER_REGISTRY_USERNAME }}
password: ${{ env.DOCKER_REGISTRY_TOKEN }}
- name: Pull docker image
if: env.BRANCH_TAG != 'latest' && env.BRANCH_TAG != 'development'
run: |
export BRANCH_TAG=${{ env.BRANCH_TAG }}-${{ matrix.variant }}
cd $APP_NAME
docker compose pull test || true
- name: Build docker image
run: |
export BRANCH_TAG=${{ env.BRANCH_TAG }}-${{ matrix.variant }}
make build
- name: Push docker image to docker registry
run: |
export BRANCH_TAG=${{ env.BRANCH_TAG }}-${{ matrix.variant }}
cd $APP_NAME
docker compose push test
- name: Test the structure that is generated by the template
run: |
export BRANCH_TAG=${{ env.BRANCH_TAG }}-${{ matrix.variant }}
make test_template VARIANT=${{ matrix.variant }}
- name: Test the generated app
run: |
export BRANCH_TAG=${{ env.BRANCH_TAG }}-${{ matrix.variant }}
make test_variant_app