From e7b5830a20cc66ad32409d349c37eadf9b4139b4 Mon Sep 17 00:00:00 2001 From: Mustafa Kara Date: Wed, 3 Aug 2022 12:28:07 +0300 Subject: [PATCH] Modify go.work file to include multi-product architecture repositories by default (#3516) * Fix pipelines and makefile to build multi-product architecture repositories Signed-off-by: Mustafa Kara Co-authored-by: Mattermod Co-authored-by: wiggin77 --- .dockerignore | 2 +- .github/workflows/ci.yml | 93 +++++++++++++++--- .github/workflows/dev-release.yml | 146 +++++++++++++++++++++-------- .github/workflows/lint-server.yml | 2 +- .github/workflows/prod-release.yml | 4 + build/gowork/main.go | 16 ++-- docker/Dockerfile | 3 +- 7 files changed, 204 insertions(+), 62 deletions(-) diff --git a/.dockerignore b/.dockerignore index 8235d54cc..fa83e261b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,4 +8,4 @@ mattermost-plugin/ website/ linux/ go.work -go.work.sum \ No newline at end of file +go.work.sum diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73b75e20e..8b66ab562 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,10 @@ on: pull_request: workflow_dispatch: +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + EXCLUDE_ENTERPRISE: true + jobs: ci-ubuntu-server: @@ -23,26 +27,57 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - + with: + path: "focalboard" + - id: "mattermostServer" + uses: actions/checkout@v3 + continue-on-error: true + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref: ${{ env.BRANCH_NAME }} + - uses: actions/checkout@v3 + if: steps.mattermostServer.outcome == 'failure' + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref : "master" - name: Set up Go uses: actions/setup-go@v3 with: go-version: 1.18.1 - name: "Test server: ${{matrix['db']}}" - run: make server-test-${{matrix['db']}} + run: cd focalboard; make server-test-${{matrix['db']}} ci-ubuntu-webapp: runs-on: ubuntu-18.04 - steps: - name: Checkout uses: actions/checkout@v3 - + with: + path: "focalboard" + - id: "mattermostServer" + uses: actions/checkout@v3 + continue-on-error: true + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref: ${{ env.BRANCH_NAME }} + - uses: actions/checkout@v3 + if: steps.mattermostServer.outcome == 'failure' + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref : "master" - name: npm ci run: | - cd webapp && npm ci && cd - - cd mattermost-plugin/webapp && npm ci + cd focalboard/webapp && npm ci && cd - + cd focalboard/mattermost-plugin/webapp && npm ci - name: Set up Go uses: actions/setup-go@v3 @@ -55,19 +90,19 @@ jobs: node-version: 16.1.0 - name: Build Linux server - run: make server-linux-package + run: cd focalboard; make server-linux-package - name: Copy server binary for Cypress - run: cp bin/linux/focalboard-server bin/ + run: cp focalboard/bin/linux/focalboard-server focalboard/bin/ - name: Upload server package uses: actions/upload-artifact@v1 with: name: focalboard-server-linux-amd64.tar.gz - path: ${{ github.workspace }}/dist/focalboard-server-linux-amd64.tar.gz + path: ${{ github.workspace }}/focalboard/dist/focalboard-server-linux-amd64.tar.gz - name: Lint & test webapp - run: make webapp-ci + run: cd focalboard; make webapp-ci ci-windows-server: runs-on: windows-2022 @@ -80,6 +115,23 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + path: "focalboard" + - id: "mattermostServer" + uses: actions/checkout@v3 + continue-on-error: true + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref: ${{ env.BRANCH_NAME }} + - uses: actions/checkout@v3 + if: steps.mattermostServer.outcome == 'failure' + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref : "master" - name: Set up Go uses: actions/setup-go@v3 @@ -87,7 +139,7 @@ jobs: go-version: 1.18.1 - name: "Test server (minimum): ${{matrix['db']}}" - run: make server-test-mini-${{matrix['db']}} + run: cd focalboard; make server-test-mini-${{matrix['db']}} ci-mac-server: runs-on: macos-11 @@ -100,6 +152,23 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + path: "focalboard" + - id: "mattermostServer" + uses: actions/checkout@v3 + continue-on-error: true + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref: ${{ env.BRANCH_NAME }} + - uses: actions/checkout@v3 + if: steps.mattermostServer.outcome == 'failure' + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref : "master" - name: Set up Go uses: actions/setup-go@v3 @@ -107,4 +176,4 @@ jobs: go-version: 1.18.1 - name: "Test server (minimum): ${{matrix['db']}}" - run: make server-test-mini-${{matrix['db']}} + run: cd focalboard; make server-test-mini-${{matrix['db']}} diff --git a/.github/workflows/dev-release.yml b/.github/workflows/dev-release.yml index 9bf05309c..2376c1f1d 100644 --- a/.github/workflows/dev-release.yml +++ b/.github/workflows/dev-release.yml @@ -7,29 +7,49 @@ on: branches: [ main, release-** ] workflow_dispatch: +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + EXCLUDE_ENTERPRISE: true + jobs: ubuntu: runs-on: ubuntu-18.04 - + steps: - - name: Checkout + - uses: actions/checkout@v3 + with: + path: "focalboard" + - id: "mattermostServer" uses: actions/checkout@v3 + continue-on-error: true + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref: ${{ env.BRANCH_NAME }} + - uses: actions/checkout@v3 + if: steps.mattermostServer.outcome == 'failure' + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref : "master" - name: Replace token 1 server - run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/server/services/telemetry/telemetry.go + run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/focalboard/server/services/telemetry/telemetry.go - name: Replace token 1 webapp - run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/mattermost-plugin/webapp/src/index.tsx + run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/focalboard/mattermost-plugin/webapp/src/index.tsx - name: Replace token 2 server - run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/server/services/telemetry/telemetry.go + run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/focalboard/server/services/telemetry/telemetry.go - name: Replace token 2 webapp - run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/mattermost-plugin/webapp/src/index.tsx + run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/focalboard/mattermost-plugin/webapp/src/index.tsx - name: npm ci - run: cd webapp; npm ci --no-optional + run: cd focalboard/webapp; npm ci --no-optional - name: Set up Go uses: actions/setup-go@v3 @@ -51,7 +71,7 @@ jobs: run: sudo apt-get install libwebkit2gtk-4.0-dev - name: Build Linux server and app - run: make server-linux-package linux-app + run: cd focalboard/; make server-linux-package linux-app env: BUILD_NUMBER: ${{ github.run_id }} @@ -59,13 +79,13 @@ jobs: uses: actions/upload-artifact@v3 with: name: focalboard-server-linux-amd64.tar.gz - path: ${{ github.workspace }}/dist/focalboard-server-linux-amd64.tar.gz + path: ${{ github.workspace }}/focalboard/dist/focalboard-server-linux-amd64.tar.gz - name: Upload app package uses: actions/upload-artifact@v3 with: name: focalboard-linux.tar.gz - path: ${{ github.workspace }}/linux/dist/focalboard-linux.tar.gz + path: ${{ github.workspace }}/focalboard/linux/dist/focalboard-linux.tar.gz macos: runs-on: macos-11 @@ -74,21 +94,37 @@ jobs: - name: Checkout uses: actions/checkout@v3 - + with: + path: "focalboard" + - id: "mattermostServer" + uses: actions/checkout@v3 + continue-on-error: true + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref: ${{ env.BRANCH_NAME }} + - uses: actions/checkout@v3 + if: steps.mattermostServer.outcome == 'failure' + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref : "master" - name: Replace token 1 server - run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/server/services/telemetry/telemetry.go + run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/focalboard/server/services/telemetry/telemetry.go - name: Replace token 1 webapp - run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/mattermost-plugin/webapp/src/index.tsx + run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/focalboard/mattermost-plugin/webapp/src/index.tsx - name: Replace token 2 server - run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/server/services/telemetry/telemetry.go + run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/focalboard/server/services/telemetry/telemetry.go - name: Replace token 2 webapp - run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/mattermost-plugin/webapp/src/index.tsx + run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/focalboard/mattermost-plugin/webapp/src/index.tsx - name: npm ci - run: cd webapp; npm ci --no-optional + run: cd focalboard/webapp; npm ci --no-optional - name: Set up Go uses: actions/setup-go@v3 @@ -99,7 +135,7 @@ jobs: run: ls -n /Applications/ | grep Xcode* - name: Build macOS - run: make mac-app + run: cd focalboard; make mac-app env: DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer BUILD_NUMBER: ${{ github.run_id }} @@ -108,7 +144,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: focalboard-mac.zip - path: ${{ github.workspace }}/mac/dist/focalboard-mac.zip + path: ${{ github.workspace }}/focalboard/mac/dist/focalboard-mac.zip windows: runs-on: windows-2022 @@ -116,24 +152,40 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - + with: + path: "focalboard" + - id: "mattermostServer" + uses: actions/checkout@v3 + continue-on-error: true + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref: ${{ env.BRANCH_NAME }} + - uses: actions/checkout@v3 + if: steps.mattermostServer.outcome == 'failure' + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref : "master" - name: Replace token 1 server - run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/server/services/telemetry/telemetry.go + run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/focalboard/server/services/telemetry/telemetry.go - name: Replace token 1 webapp - run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/mattermost-plugin/webapp/src/index.tsx + run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/focalboard/mattermost-plugin/webapp/src/index.tsx - name: Replace token 2 server - run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/server/services/telemetry/telemetry.go + run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/focalboard/server/services/telemetry/telemetry.go - name: Replace token 2 webapp - run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/mattermost-plugin/webapp/src/index.tsx + run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/focalboard/mattermost-plugin/webapp/src/index.tsx - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.1 - name: npm ci - run: cd webapp; npm ci --no-optional + run: cd focalboard/webapp; npm ci --no-optional - name: Set up Go uses: actions/setup-go@v3 @@ -146,10 +198,10 @@ jobs: nuget-version: '5.x' - name: NuGet Restore - run: nuget restore win-wpf\Focalboard.sln + run: nuget restore focalboard\win-wpf\Focalboard.sln - name: Build Windows WPF app - run: make win-wpf-app + run: cd focalboard; make win-wpf-app env: BUILD_NUMBER: ${{ github.run_id }} @@ -157,35 +209,51 @@ jobs: uses: actions/upload-artifact@v3 with: name: focalboard.msix - path: ${{ github.workspace }}/win-wpf/focalboard.msix + path: ${{ github.workspace }}/focalboard/win-wpf/focalboard.msix - name: Upload app zip package uses: actions/upload-artifact@v3 with: name: focalboard-win.zip - path: ${{ github.workspace }}/win-wpf/dist/focalboard-win.zip + path: ${{ github.workspace }}/focalboard/win-wpf/dist/focalboard-win.zip plugin: runs-on: ubuntu-18.04 steps: - - name: Checkout + - uses: actions/checkout@v3 + with: + path: "focalboard" + - id: "mattermostServer" uses: actions/checkout@v3 + continue-on-error: true + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref: ${{ env.BRANCH_NAME }} + - uses: actions/checkout@v3 + if: steps.mattermostServer.outcome == 'failure' + with: + repository: "mattermost/mattermost-server" + fetch-depth: "20" + path: "mattermost-server" + ref : "master" - name: Replace token 1 server - run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/server/services/telemetry/telemetry.go + run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/focalboard/server/services/telemetry/telemetry.go - name: Replace token 1 webapp - run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/mattermost-plugin/webapp/src/index.tsx + run: sed -i -e "s,placeholder_rudder_dataplane_url,${{ secrets.RUDDER_DATAPLANE_URL }},g" ${{ github.workspace }}/focalboard/mattermost-plugin/webapp/src/index.tsx - name: Replace token 2 server - run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/server/services/telemetry/telemetry.go + run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/focalboard/server/services/telemetry/telemetry.go - name: Replace token 2 webapp - run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/mattermost-plugin/webapp/src/index.tsx + run: sed -i -e "s,placeholder_rudder_key,${{ secrets.RUDDER_DEV_KEY }},g" ${{ github.workspace }}/focalboard/mattermost-plugin/webapp/src/index.tsx - name: npm ci - run: cd webapp; npm ci --no-optional + run: cd focalboard/webapp; npm ci --no-optional - name: Set up Go uses: actions/setup-go@v3 @@ -198,21 +266,21 @@ jobs: node-version: 16.1.0 - name: Build webapp - run: make webapp + run: cd focalboard; make webapp - name: npm ci plugin dependencies - run: cd mattermost-plugin/webapp; npm ci --no-optional + run: cd focalboard/mattermost-plugin/webapp; npm ci --no-optional - name: Build plugin - run: cd mattermost-plugin; make dist + run: cd focalboard/mattermost-plugin; make dist env: BUILD_NUMBER: ${{ github.run_id }} - name: Rename plugin file - run: cd mattermost-plugin/dist; mv focalboard-*.tar.gz mattermost-plugin-focalboard.tar.gz + run: cd focalboard/mattermost-plugin/dist; mv focalboard-*.tar.gz mattermost-plugin-focalboard.tar.gz - name: Upload plugin artifact uses: actions/upload-artifact@v3 with: name: mattermost-plugin-focalboard.tar.gz - path: ${{ github.workspace }}/mattermost-plugin/dist/mattermost-plugin-focalboard.tar.gz + path: ${{ github.workspace }}/focalboard/mattermost-plugin/dist/mattermost-plugin-focalboard.tar.gz diff --git a/.github/workflows/lint-server.yml b/.github/workflows/lint-server.yml index ea141a603..32e237db5 100644 --- a/.github/workflows/lint-server.yml +++ b/.github/workflows/lint-server.yml @@ -9,7 +9,7 @@ on: env: BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - USE_LOCAL_MATTERMOST-SERVER_REPO: true + EXCLUDE_ENTERPRISE: true jobs: golangci: diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml index 792704a83..d08e246d4 100644 --- a/.github/workflows/prod-release.yml +++ b/.github/workflows/prod-release.yml @@ -2,6 +2,10 @@ name: Production-Release on: workflow_dispatch +env: + EXCLUDE_SERVER: true + EXCLUDE_ENTERPRISE: true + jobs: ubuntu: diff --git a/build/gowork/main.go b/build/gowork/main.go index cf66452c6..c962369d5 100644 --- a/build/gowork/main.go +++ b/build/gowork/main.go @@ -39,30 +39,30 @@ func main() { } fmt.Fprintln(os.Stdout, "go.work written successfully.") + fmt.Fprintln(os.Stdout, content) } func makeGoWork(ci bool) string { - repos := []string{ - "mattermost-server", - "enterprise", + repos := map[string]string{ + "../mattermost-server": "EXCLUDE_SERVER", + "../enterprise": "EXCLUDE_ENTERPRISE", + "./mattermost-plugin": "EXCLUDE_PLUGIN", } var b strings.Builder b.WriteString("go 1.18\n\n") - b.WriteString("use ./mattermost-plugin\n") b.WriteString("use ./server\n") - for repoIdx := range repos { - if isEnvVarTrue(fmt.Sprintf("USE_LOCAL_%s_REPO", strings.ToUpper(repos[repoIdx])), true) { - b.WriteString(fmt.Sprintf("use ../%s\n", repos[repoIdx])) + for repo, envVarName := range repos { + if !isEnvVarTrue(envVarName, true) { + b.WriteString(fmt.Sprintf("use %s\n", repo)) } } if ci { b.WriteString("use ./linux\n") } - return b.String() } diff --git a/docker/Dockerfile b/docker/Dockerfile index 231cc649b..eb7a054e7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -13,7 +13,8 @@ FROM golang:1.18.3@sha256:b203dc573d81da7b3176264bfa447bd7c10c9347689be405403818 WORKDIR /go/src/focalboard ADD . /go/src/focalboard -RUN make server-linux + +RUN EXCLUDE_PLUGIN=true EXCLUDE_SERVER=true EXCLUDE_ENTERPRISE=true make server-linux RUN mkdir /data ## Final image