Welcome to mirror list, hosted at ThFree Co, Russian Federation.

build-docker.yml « workflows « .github - github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b840c7634b50c0e3cbc73f7f3e176e84428ca7ed (plain)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# https://www.docker.com/blog/docker-v2-github-action-is-now-ga/
# https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/
# https://docs.github.com/en/actions/guides/publishing-docker-images

name: 'Docker Integration Tests and Release'

on:
  workflow_call:
    inputs:
      git_ref:
        required: true
        type: string
      arch:
        required: false
        type: string
        default: 'x86'
  push:
    branches:
      - master
      - devel
  pull_request:
    branches:
      - master
      - devel

jobs:
  build:
    if: ${{ github.repository == 'nextcloud/nextcloudpi' }}
    runs-on: ubuntu-latest
    env:
      VERSION: "${{ inputs.git_ref || github.ref }}"
    steps:
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1
      - name: Setup Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1

      - name: Checkout code
        uses: actions/checkout@v3
        with:
          ref: "${{ env.VERSION }}"

      - name: Login to docker
        run: |
          echo "${{ secrets.DOCKER_PASSWORD_INTERNAL }}" | docker login -u "${{ secrets.DOCKER_LOGIN_INTERNAL }}" --password-stdin

      - name: Build images
        id: build-container
        run: |
          ./build/build-docker.sh "${{ inputs.arch }}"
          docker tag "ownyourbits/nextcloudpi-${{ inputs.arch }}:latest" "thecalcaholic/ncp-internal-${{ inputs.arch }}:${{ github.run_id }}"
          testing_image="ownyourbits/nextcloudpi-${{ inputs.arch }}:latest"
          [[ "${{ inputs.arch }}" == "arm64" ]] && testing_image="ownyourbits/ncp-qemu-fix-${{ inputs.arch }}:latest"
          docker tag "${testing_image}" "thecalcaholic/ncp-internal-${{ inputs.arch }}:${{ github.run_id }}-testing"
          docker push "thecalcaholic/ncp-internal-${{ inputs.arch }}:${{ github.run_id }}"
          docker push "thecalcaholic/ncp-internal-${{ inputs.arch }}:${{ github.run_id }}-testing"

  update-test:
    needs:
      - build
    runs-on: ubuntu-latest
    env:
      VERSION: "${{ inputs.git_ref || github.ref }}"

    steps:
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1

      - name: Start ncp container
        run: |
          docker volume create ncdata
          docker run --platform "linux/${{ inputs.arch }}" -v ncdata:/data -d --rm -p 8443:443 -p 4443:4443 --name nextcloudpi ownyourbits/nextcloudpi:latest

      - name: Checkout code
        uses: actions/checkout@v3
        with:
          ref: "${{ env.VERSION }}"

      - name: Setup Firefox
        uses: browser-actions/setup-firefox@latest
      - name: Setup GeckoDriver
        uses: browser-actions/setup-geckodriver@latest
      - name: Setup Selenium
        run: pip install selenium

      - name: Activate container
        working-directory: ./tests
        run: |
          docker logs nextcloudpi |& awk '{ print "CONTAINER::" $0 }'
          echo 'CONTAINER:: =========='
          docker logs -f nextcloudpi |& awk '{ print "CONTAINER::" $0 }' &
          docker exec nextcloudpi bash -c 'tail -f /var/log/ncp.log' |& awk '{ print "NCP::" $0 }' &
          cmd=(python activation_tests.py --no-gui localhost 8443 4443)
          [[ "${{ inputs.arch }}" == "x86" ]] || cmd+=(--timeout 300)
          
          success=false
          for attempt in {1..3}
          do
            echo ":: Activation Tests (attempt $attempt/3) ::"
            "${cmd[@]}" || {
              tail -n 20 geckodriver.log >&2 || true
              echo "CI:: Activation test (attempt $attempt/3) failed!"
              docker exec nextcloudpi bash /usr/local/bin/ncp-diag
              sleep 12
              continue
            }
            success=true
            break
          done
          [[ "$success" == "true" ]] || {
            echo "CI:: Activation test failed in all attempts!"
            exit 1
          }
          echo "CI:: Activation test successful"
      - name: Start new container
        run: |
          docker stop nextcloudpi
          docker run -d -v ncdata:/data --rm -p 8443:443 -p 4443:4443 --name nextcloudpi thecalcaholic/ncp-internal-${{ inputs.arch }}:${{ github.run_id }}-testing
      - name: Integration Tests
        working-directory: ./tests
        run: |
          docker logs nextcloudpi |& awk '{ print "CONTAINER::" $0 }'
          echo 'CONTAINER:: =========='
          docker logs -f nextcloudpi |& awk '{ print "CONTAINER::" $0 }' &
          docker exec nextcloudpi bash -c 'tail -f /var/log/ncp.log' |& awk '{ print "NCP::" $0 }' &
          cmd=(python activation_tests.py --no-gui localhost 8443 4443)
          [[ "${{ inputs.arch }}" == "x86" ]] || cmd+=(--timeout 300)
                    
          success=false
          for attempt in {1..3}
          do
            echo ":: System Tests (attempt $attempt/3) ::"
            python system_tests.py --no-ping --non-interactive || {
              echo "CI:: System test (attempt $attempt) failed!"
              continue
            }
            success=true
            break
          done
          [[ "$success" == "true" ]] || {
            echo "CI:: System test failed in all attempts!"
            exit 1
          }
          echo "CI:: System test successful"
          
          success=false
          for attempt in {1..3}
          do
            echo ":: Nextcloud Tests (attempt $attempt/3) ::"
            python nextcloud_tests.py --no-gui localhost 8443 4443 || {
              tail -n 20 geckodriver.log >&2 || true
              echo "CI:: Nextcloud test (attempt $attempt/3) failed!"
              continue
            }
            success=true
            break
          done
          [[ "$success" == "true" ]] || {
            echo "CI:: Nextcloud test failed in all attempts!"
            exit 1
          }
          echo "CI:: Nextcloud test successful"

  test:
    needs:
      - build
    runs-on: ubuntu-latest
    env:
      VERSION: "${{ inputs.git_ref || github.ref }}"

    steps:
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1

      - name: Login to docker
        run: |
          echo "${{ secrets.DOCKER_PASSWORD_INTERNAL }}" | docker login -u "${{ secrets.DOCKER_LOGIN_INTERNAL }}" --password-stdin
      - name: Start ncp container
        run: |
          docker run -d --rm -p 8443:443 -p 4443:4443 --name nextcloudpi thecalcaholic/ncp-internal-${{ inputs.arch }}:${{ github.run_id }}-testing

      - name: Checkout code
        uses: actions/checkout@v3
        with:
          ref: "${{ env.VERSION }}"

      - name: Setup Firefox
        uses: browser-actions/setup-firefox@latest
      - name: Setup GeckoDriver
        uses: browser-actions/setup-geckodriver@latest
      - name: Setup Selenium
        run: pip install selenium

      - name: Integration Tests
        working-directory: ./tests
        run: |
          docker logs nextcloudpi |& awk '{ print "CONTAINER::" $0 }'
          echo 'CONTAINER:: =========='
          docker logs -f nextcloudpi |& awk '{ print "CONTAINER::" $0 }' &
          docker exec nextcloudpi bash -c 'tail -f /var/log/ncp.log' |& awk '{ print "NCP::" $0 }' &
          cmd=(python activation_tests.py --no-gui localhost 8443 4443)
          [[ "${{ inputs.arch }}" == "x86" ]] || cmd+=(--timeout 300)
          
          success=false
          for attempt in {1..3}
          do
            echo ":: Activation Tests (attempt $attempt/3) ::"
            "${cmd[@]}" || {
              tail -n 20 geckodriver.log >&2 || true
              echo "CI:: Activation test (attempt $attempt/3) failed!"
              docker exec nextcloudpi bash /usr/local/bin/ncp-diag
              sleep 12
              continue
            }
            success=true
            break
          done
          [[ "$success" == "true" ]] || {
            echo "CI:: Activation test failed in all attempts!"
            exit 1
          }
          echo "CI:: Activation test successful"
          
          success=false
          for attempt in {1..3}
          do
            echo ":: System Tests (attempt $attempt/3) ::"
            python system_tests.py --no-ping --non-interactive || {
              echo "CI:: System test (attempt $attempt) failed!"
              continue
            }
            success=true
            break
          done
          [[ "$success" == "true" ]] || {
            echo "CI:: System test failed in all attempts!"
            exit 1
          }
          echo "CI:: System test successful"
          
          success=false
          for attempt in {1..3}
          do
            echo ":: Nextcloud Tests (attempt $attempt/3) ::"
            python nextcloud_tests.py --no-gui localhost 8443 4443 || {
              tail -n 20 geckodriver.log >&2 || true
              echo "CI:: Nextcloud test (attempt $attempt/3) failed!"
              continue
            }
            success=true
            break
          done
          [[ "$success" == "true" ]] || {
            echo "CI:: Nextcloud test failed in all attempts!"
            exit 1
          }
          echo "CI:: Nextcloud test successful"