diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 000000000..066512546 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,39 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: build-and-test + +on: + workflow_call: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Node LTS + uses: actions/setup-node@v3 + with: + node-version: lts/* + - name: Install dependencies + run: npm ci + - name: Build packages + run: npm run build + + test: + runs-on: ubuntu-latest + needs: build + steps: + - name: Add hosts for integration tests + run: sudo echo "127.0.0.1 localhost auth.example.com matrix.example.com matrix1.example.com matrix2.example.com matrix3.example.com federation.example.com" | sudo tee -a /etc/hosts + - uses: actions/checkout@v3 + - name: Set up Node LTS + uses: actions/setup-node@v3 + with: + node-version: lts/* + - name: Install dependencies + run: npm ci + - name: Install playwright test browsers + run: npx playwright install + - name: Run all tests + run: npm test \ No newline at end of file diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml deleted file mode 100644 index f5ab0a2e4..000000000 --- a/.github/workflows/github-ci.yml +++ /dev/null @@ -1,105 +0,0 @@ -# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs - -name: Node.js CI - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Node LTS - uses: actions/setup-node@v3 - with: - node-version: lts/* - - name: Install dependencies - run: npm ci - - name: Build packages - run: npm run build - - test: - runs-on: ubuntu-latest - needs: build - steps: - - name: Add hosts for integration tests - run: sudo echo "127.0.0.1 localhost auth.example.com matrix.example.com matrix1.example.com matrix2.example.com matrix3.example.com federation.example.com" | sudo tee -a /etc/hosts - - uses: actions/checkout@v3 - - name: Set up Node LTS - uses: actions/setup-node@v3 - with: - node-version: lts/* - - name: Install dependencies - run: npm ci - - name: Install playwright test browsers - run: npx playwright install - - name: Run all tests - run: npm test - - publish-docker: - runs-on: ubuntu-latest - needs: test - if: github.event_name == 'push' - steps: - - uses: actions/checkout@v3 - - name: Get all src files that have changed - id: changed-files - uses: tj-actions/changed-files@v41 - with: - files: packages/matrix-invite/**/* - - name: Build and publish matrix-invite docker image - if: steps.changed-files.outputs.test_any_changed == 'true' - uses: philips-software/docker-ci-scripts@v5.1.0 - with: - base-dir: "${{ github.workspace }}/packages/matrix-invite/" - dockerfile: "${{ github.workspace }}/packages/matrix-invite/Dockerfile" - image-name: "twake-matrix-invite" - tags: "latest" - env: - REGISTRY_USERNAME: ${{ secrets.DOCKERHUB_USER }} - REGISTRY_TOKEN: "${{ secrets.DOCKERHUB_PASSWORD }}" - DOCKER_ORGANIZATION: twaketech - - update-doc: - runs-on: ubuntu-latest - needs: test - if: github.event_name == 'pull_request' - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.ref }} - - name: Set up Node LTS - uses: actions/setup-node@v3 - with: - node-version: lts/* - - name: Install dependencies - run: npm ci - - name: Generate Swagger documentation - run: npm run doc - - name: Check if documentation files has changed - id: verify-changed-files - uses: tj-actions/verify-changed-files@v17 - with: - files: docs/openapi.json - - name: Update documentation files - if: steps.verify-changed-files.outputs.files_changed == 'true' - env: - SPEC_TO_DISPLAY: "openapi.json" - DISABLE_TRY_IT_OUT_JS_METHOD: "const DisableTryItOutPlugin = function() {return {statePlugins:{spec:{wrapSelectors:{allowTryItOutFor:() => () => false}}}}}" - DISABLE_TRY_IT_OUT_PLUGIN: ", DisableTryItOutPlugin" - run: | - yes | cp -rf node_modules/swagger-ui-dist/* docs - sed -i "/window\.onload\s=\sfunction()\s{/a $DISABLE_TRY_IT_OUT_JS_METHOD" docs/swagger-initializer.js - sed -i "s#https://petstore\.swagger\.io/v2/swagger\.json#$SPEC_TO_DISPLAY#g" docs/swagger-initializer.js - sed -i "/SwaggerUIBundle\.plugins\.DownloadUrl/a $DISABLE_TRY_IT_OUT_PLUGIN" docs/swagger-initializer.js - - name: Commit updated documentation files - if: steps.verify-changed-files.outputs.files_changed == 'true' - uses: EndBug/add-and-commit@v9 - with: - add: docs - message: 'chore: update documentation' \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 000000000..4a18f6ff0 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,14 @@ +name: pr + +on: + pull_request_target: + branches: + - main + merge_group: + workflow_dispatch: + +jobs: + test: + name: Build And Test + uses: ./.github/workflows/build-and-test.yml + secrets: inherit diff --git a/.github/workflows/publish-matrix-invite.yml b/.github/workflows/publish-matrix-invite.yml new file mode 100644 index 000000000..369a8d6a8 --- /dev/null +++ b/.github/workflows/publish-matrix-invite.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: publish-matrix-invite + +on: + workflow_call: + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Get all src files that have changed + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: | + packages/matrix-invite/**/* + .github/workflows/** + - name: Publish to dockerhub + uses: elgohr/Publish-Docker-Github-Action@v5 + with: + name: linagora/matrix-invite + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + workdir: "${{ github.workspace }}/packages/matrix-invite" + context: . + buildoptions: "-t linagora/matrix-invite -f Dockerfile" + tags: "latest" + diff --git a/.github/workflows/publish-tom-federation-server.yml b/.github/workflows/publish-tom-federation-server.yml new file mode 100644 index 000000000..1611dcf03 --- /dev/null +++ b/.github/workflows/publish-tom-federation-server.yml @@ -0,0 +1,30 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: publish-tom-federation-server + +on: + workflow_call: + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Get all src files that have changed + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: | + packages/federation-server/**/* + .github/workflows/** + - name: Publish to dockerhub + uses: elgohr/Publish-Docker-Github-Action@v5 + with: + name: linagora/tom-federation-server + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + workdir: "${{ github.workspace }}" + context: . + buildoptions: "-t linagora/tom-federation-server -f packages/federation-server/Dockerfile" + tags: "latest" diff --git a/.github/workflows/publish-tom-server.yml b/.github/workflows/publish-tom-server.yml new file mode 100644 index 000000000..e1d03efed --- /dev/null +++ b/.github/workflows/publish-tom-server.yml @@ -0,0 +1,30 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: publish-tom-server + +on: + workflow_call: + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Get all src files that have changed + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: | + packages/federation-server/**/* + .github/workflows/** + - name: Publish to dockerhub + uses: elgohr/Publish-Docker-Github-Action@v5 + with: + name: linagora/tom-server + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + workdir: "${{ github.workspace }}" + context: . + buildoptions: "-t linagora/tom-server -f Dockerfile" + tags: "latest" diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 000000000..6a9ac6cf9 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,26 @@ +on: + push: + branches: + - main + +jobs: + test: + name: Build And Test + uses: ./.github/workflows/build-and-test.yml + secrets: inherit + publish-federation-server: + name: Publish Federation Server + uses: ./.github/workflows/publish-tom-federation-server.yml + secrets: inherit + publish-tom-server: + name: Publish ToM Server + uses: ./.github/workflows/publish-tom-server.yml + secrets: inherit + publish-matrix-invite: + name: Publish Matrix Invite + uses: ./.github/workflows/publish-matrix-invite.yml + secrets: inherit + upadte-docs: + name: Update Docs + uses: ./.github/workflows/update-docs.yml + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml new file mode 100644 index 000000000..9c2c74cce --- /dev/null +++ b/.github/workflows/update-docs.yml @@ -0,0 +1,42 @@ +name: update-docs + +on: + workflow_call: + +jobs: + update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + - name: Set up Node LTS + uses: actions/setup-node@v3 + with: + node-version: lts/* + - name: Install dependencies + run: npm ci + - name: Generate Swagger documentation + run: npm run doc + - name: Check if documentation files has changed + id: verify-changed-files + uses: tj-actions/verify-changed-files@v17 + with: + files: docs/openapi.json + - name: Update documentation files + if: steps.verify-changed-files.outputs.files_changed == 'true' + env: + SPEC_TO_DISPLAY: "openapi.json" + DISABLE_TRY_IT_OUT_JS_METHOD: "const DisableTryItOutPlugin = function() {return {statePlugins:{spec:{wrapSelectors:{allowTryItOutFor:() => () => false}}}}}" + DISABLE_TRY_IT_OUT_PLUGIN: ", DisableTryItOutPlugin" + run: | + yes | cp -rf node_modules/swagger-ui-dist/* docs + sed -i "/window\.onload\s=\sfunction()\s{/a $DISABLE_TRY_IT_OUT_JS_METHOD" docs/swagger-initializer.js + sed -i "s#https://petstore\.swagger\.io/v2/swagger\.json#$SPEC_TO_DISPLAY#g" docs/swagger-initializer.js + sed -i "/SwaggerUIBundle\.plugins\.DownloadUrl/a $DISABLE_TRY_IT_OUT_PLUGIN" docs/swagger-initializer.js + - name: Commit updated documentation files + if: steps.verify-changed-files.outputs.files_changed == 'true' + uses: EndBug/add-and-commit@v9 + with: + add: docs + message: 'chore: update documentation' \ No newline at end of file