Skip to content

Commit

Permalink
[sync] 2024/03/01 (cfug#1416)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 authored Mar 2, 2024
2 parents 8ef738b + b7c1323 commit 8c36a73
Show file tree
Hide file tree
Showing 121 changed files with 3,110 additions and 2,607 deletions.
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
.gitignore
AUTHORS
CONTRIBUTING.md
docker-compose.yml
LICENSE
node_modules/
README.md
flutter/
85 changes: 60 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:

jobs:
test:
name: Check excerpts and run tests
name: Analyze and test code examples
runs-on: ubuntu-latest
if: github.repository == 'cfug/flutter.cn'
strategy:
Expand All @@ -36,10 +36,36 @@ jobs:
submodules: recursive
- name: Move docs
run: make move-docs
- name: Test
env:
FLUTTER_BUILD_BRANCH: ${{ matrix.branch }}
run: make test
- uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225
with:
channel: ${{ matrix.branch }}
- name: Fetch Dart dependencies
run: dart pub get
- name: Check Dart code formatting
run: dart run flutter_site format-dart --check
continue-on-error: ${{ matrix.experimental }}
- name: Analyze Dart code
run: dart run flutter_site analyze-dart
continue-on-error: ${{ matrix.experimental }}
- name: Run Dart tests
run: dart run flutter_site test-dart
continue-on-error: ${{ matrix.experimental }}

excerpts:
name: Check if code excerpts are up to date
runs-on: ubuntu-latest
if: github.repository == 'cfug/flutter.cn'
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
submodules: recursive
- uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: stable
- name: Fetch Dart dependencies
run: dart pub get
- name: Check if excerpts are up to date
run: dart run flutter_site refresh-excerpts --fail-on-update
continue-on-error: ${{ matrix.experimental }}

linkcheck:
Expand All @@ -53,20 +79,41 @@ jobs:
submodules: recursive
- name: Build site and check links
run: make build BUILD_CONFIGS=_config.yml,_config_stage.yml
# - name: Install Node for Firebase install
# uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
# with:
# node-version: ${{ env.NODE_VERSION }}
# - name: Install Firebase CLI
# run: npm install -g [email protected]
- name: Install Node for Firebase install
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install Firebase CLI
run: npm install -g [email protected]
- uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: stable
- name: Fetch Dart dependencies
run: dart pub get
- name: Check for broken Markdown link references
run: dart run flutter_site check-link-references
- name: Check for broken internal links
run: dart run flutter_site check-links

firebase-validate:
name: Validate Firebase configuration
runs-on: ubuntu-latest
if: github.repository == 'cfug/flutter.cn'
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
submodules: recursive
- uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
with:
sdk: stable
- run: tool/check-links.sh
- name: Fetch Dart dependencies
run: dart pub get
- name: Validate the firebase.json file
run: dart run flutter_site verify-firebase-json

deploy:
name: Deploy to production
needs: [test, linkcheck]
needs: [test, excerpts, linkcheck, firebase-validate]
runs-on: ubuntu-latest
if: |
github.event_name == 'push'
Expand All @@ -78,18 +125,6 @@ jobs:
submodules: recursive
- name: Build site
run: make build
# - name: Install Node for Firebase install
# uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
# with:
# node-version: ${{ env.NODE_VERSION }}
# - name: Install Firebase CLI
# run: npm install -g [email protected]
# - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
# with:
# sdk: stable
# - run: tool/check-links.sh
# - name: Deploy to Firebase hosting
# run: make deploy # TODO(drewroengoogle) Run deploy on Cloud Build.
- name: Deploy CN
run: make deploy
env:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _site
*.swp
build
node_modules
flutter/
./flutter/

# Dart and Flutter, build related
.dart_tool
Expand Down
81 changes: 2 additions & 79 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ RUN apt-get update && apt-get install -yq --no-install-recommends \
build-essential \
ca-certificates \
curl \
diffutils \
git \
gnupg \
lsof \
Expand All @@ -27,39 +26,8 @@ RUN apt-get update && apt-get install -yq --no-install-recommends \

WORKDIR /app



# ============== INSTALL FLUTTER ==============
FROM base AS flutter

COPY ./site-shared ./site-shared
COPY pubspec.yaml ./

ARG FLUTTER_BUILD_BRANCH=stable
ENV FLUTTER_BUILD_BRANCH=$FLUTTER_BUILD_BRANCH
ENV FLUTTER_ROOT=flutter
ENV FLUTTER_BIN=flutter/bin
ENV PATH="/flutter/bin:$PATH"

RUN git clone --branch $FLUTTER_BUILD_BRANCH --single-branch --filter=tree:0 https://github.com/flutter/flutter /flutter/
VOLUME /flutter

#ENV PUB_HOSTED_URL="https://pub.flutter-io.cn"
#ENV FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"

# Set up Flutter
# NOTE You will get a warning "Woah! You appear to be trying to run flutter as root."
# and this is to be disregarded since this image is never deployed to production.
RUN flutter doctor
RUN flutter config --no-analytics \
&& flutter config --no-cli-animations \
&& flutter --version
RUN dart pub get



# ============== NODEJS INTSALL ==============
FROM flutter AS node
FROM base AS node

RUN mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
Expand All @@ -68,51 +36,6 @@ RUN mkdir -p /etc/apt/keyrings \
&& apt-get install nodejs -yq \
&& npm install -g npm # Ensure latest npm


# ============== FLUTTER CODE TESTS ==============
FROM flutter AS tests

COPY ./ ./

# Only test the code here, checking links is purely for site deployment
ENTRYPOINT ["tool/test.sh"]


# ============== DEV / JEKYLL SETUP ==============
FROM node AS dev

#RUN gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/
#RUN bundle config mirror.https://rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems

ENV JEKYLL_ENV=development
ENV RUBY_YJIT_ENABLE=1
RUN gem install bundler
COPY Gemfile Gemfile.lock ./
RUN bundle config set force_ruby_platform true
RUN bundle install

# Install Node deps
ENV NODE_ENV=development
COPY package.json package-lock.json ./
RUN npm ci

COPY ./ ./

# Jekyl ports
EXPOSE 35730
EXPOSE 4002

# Firebase emulator port
# Airplay runs on :5000 by default now
EXPOSE 5502

RUN tool/move_docs.sh

# ============== BUILD DEV JEKYLL SITE ==============
FROM dev as dev-build

RUN tool/move_docs.sh; tool/translator/build.sh

# ============== BUILD PROD JEKYLL SITE ==============
FROM node AS build

Expand All @@ -129,7 +52,7 @@ RUN npm ci

COPY ./ ./

# RUN echo $'User-agent: *\nAllow: /' > src/robots.txt
# RUN echo 'User-agent: *\nDisallow:\n\nSitemap: https://docs.flutter.dev/sitemap.xml' > src/robots.txt

ARG BUILD_CONFIGS=_config.yml
ENV BUILD_CONFIGS=$BUILD_CONFIGS
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.3)
activesupport (7.1.3.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
Expand Down Expand Up @@ -70,7 +70,7 @@ GEM
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0)
mini_portile2 (2.8.5)
minitest (5.21.2)
minitest (5.22.2)
mutex_m (0.2.0)
nokogiri (1.16.2)
mini_portile2 (~> 2.8.2)
Expand Down
Loading

0 comments on commit 8c36a73

Please sign in to comment.