I found this link
https://github.com/flutter/flutter/issues/32540#issuecomment-491498679
and tried out the fix but sadly it didn't work for me.
Hoping you can help!!
Thanks
also I'm using aws amplify hosting using this setting
version: 1
frontend:
phases:
preBuild:
commands:
- git clone https://github.com/flutter/flutter.git -b stable --depth 1
- export PATH="$PATH:`pwd`/flutter/bin"
# IMPORTANT - Please verify your build commands
build:
commands:
- flutter build web -t ./lib/main.dart
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: build/web
files:
- '**/*'
cache:
paths: []
Flutter web doesn't support images of SVG format. Please use png instead.
Related
We want to make our integration tests work on Linux desktop (ubuntu-latest) via Github Actions.
The command is
flutter config --enable-linux-desktop
flutter test -d linux integration_test
But we always get an error:
Error waiting for a debug connection: The log reader stopped unexpectedly, or never started.
//...
TestDeviceException(Unable to start the app on the device.)
package:flutter_tools/src/test/integration_test_device.dart 61:7 IntegrationTestTestDevice.start
Can Github Actions not handle the GPU / GUI related stuff fast enough on the CPU or what is going on. Is this even possible?
I found only one repository which call similar command for a linux environment.
Thanks!
I saw this question, where Xvfb was mentioned in an answer, it worked:
jobs:
linux:
runs-on: ubuntu-latest
...
steps:
run: |
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
flutter test -d linux integration_test
I am using the GabrielBB/xvfb-action#v1.6 github action to enable xvfb.
- name: flutter test
uses: GabrielBB/xvfb-action#v1.6
with:
working-directory: ./examples/flutter
run: |
flutter config --enable-linux-desktop
flutter test integration_test/basics_test.dart -d linux
I'm trying to publish my flutter page on gitlab which is the git host of my project. I'm using the ci configure like the following(from this post)
gitlab page CI configure
image: cirrusci/flutter:latest
before_script:
- flutter channel stable
- flutter upgrade
- flutter config --enable-web
- flutter pub get
pages:
stage: deploy
script:
- flutter build web
- cp -r build/web public
artifacts:
paths:
- public
only:
- live
The ci job failed in an error like:
...
$ flutter channel stable
Switching to flutter channel 'stable'...
git: fatal: 'origin/stable' is not a commit and a branch 'stable' cannot be created from it
Switching channels failed with error code 128.
...
What's the problem?
One thing worth to note is my flutter project locate in a subdirectory(ie., my-flutter-dir) of the repository root. Is it the reason? How to configure the CI script in this situation?
I've tried to add a cd my-flutter-dir as the first command in the before_script, but it still result in the same error.
It's turn out being an issue of the docker image. After I removed the flutter channel and flutter upgrade command in the befor_script part, everything is ok now.
Note if you have the flutter project in a subdirectory under the repository root, still you need to add cd you-flutter-dir command in the before_script. Also don't forget to put the .gitlab-ci.yml file in the root of the repository.
[UPDATED checkout the issue with steps on github ]
running my flutter web app locally
flutter run -d chrome --dart-define=FLUTTER_WEB_USE_SKIA=true --release
works as intended (video), but building it and deploying it to github pages (here)
flutter_master build web --dart-define=FLUTTER_WEB_USE_SKIA=true --release
doesn't access some asset, but successfully access others.
I've tried these solutions (one, two)
'about.json' works as expected locally but fails to load when deployed
while 'assets/about.json' doesn't work in either cases
the code in use can be simplified as
rootBundle.loadString('about.json');
I double-checked pubspec.yaml
flutter:
uses-material-design: true
assets:
- background_portrait.jpg
- background_landscape.jpg
- yf_icon_black.png
- yf_logo.png
- about.json
- apps.json
- news.json
- opensource.json
and the assets in the build folder
everything checks out, but the issue still persists
in these logs you can see that those files are present
What worked for me was to eliminate the assets folder completely. I created a folder for each of my asset types in the root dir (same level as lib) and referenced them as directories in pubspec.yaml:
assets:
- json/
- avatars/
Then when loading them I used a relative path as:
await rootBundle.loadString('json/structure.json');
Flutter creates an assets folder during build and copies all my asset directories into it. This way it worked for me to load the assets both in debug and in release mode on GitLab Pages.
EDIT: I include the gitlab.ci.yml file I use for gitlab pages build pipeline
image: registry.gitlab.com/famedly/containers/flutter-dockerimages:beta
pages:
script:
- flutter clean
- flutter config --enable-web
- flutter pub get
- flutter build web --release
- ls build/web
- cp -r build/web public
- ls public
artifacts:
paths:
- public
only:
- master
The ls commands you do not need these were just for logging the output during development of the script. I left them there because they do no harm and could come handy sometime.
The official flutter documentation explains that the assets should be added relative to the path of pubspec.yaml
For your example of pubspec.yaml, you should either move the asset files in the root of you project folder or if they are located in an assets sub folder add the name of that sub folder in pubspec.yaml
E.g. if your files are located under project_path/assets/, the assets section of your pubspec.yaml should look something like:
flutter:
uses-material-design: true
assets:
- assets/background_portrait.jpg
- assets/background_landscape.jpg
- assets/yf_icon_black.png
- assets/yf_logo.png
- assets/about.json
- assets/apps.json
- assets/news.json
- assets/opensource.json
In your dart code, assets should be accessed by their specified key, for the above example use 'assets/about.json' and not 'about.json'
Its an old thread - just in case someone stumbles upon...you have to ensure that a valid certificate is in place. Otherwise the service worker will not start.
I have a problem deploying Ionic 4 app to Github pages.
I tried follwing a tutorial for uploading Angular app but it does not work. It keeps throwing errors of all kinds.
Does anyone can help?
Thanks a lot.
Here is how to use angular-cli-ghpages with Ionic 4:
Create your Ionic project (ionic start MyApp blank)
Install the plugin: npm i angular-cli-ghpages --save
Connect your project with your github repository.
Navigate in the terminal to your project directory and execute ionic build --prod -- --base-href https://YOUR_GITHUB_USERNAME.github.io/YOUR_PROJECT_NAME/, what will create the www folder, which is comparable to the dist folder for Angular. It also sets your github page domain as base href in index.html.
Then run the plugin: npx angular-cli-ghpages --dir=www. The flag at the end points to the www folder, where the index.html file is located that will be displayed at https://YOUR_GITHUB_USERNAME.github.io/YOUR_PROJECT_NAME/. The plugin will create a branch called "gh-pages" in your project that contains all files which are located in your www folder.
As a last step you have to select the "gh-page" branch in the settings of your project (https://YOUR_GITHUB_USERNAME.github.io/YOUR_PROJECT_NAME/settings) as a source for your github page.
You can also set different branch names if you don't want to use the default "gh-pages" name (also master is possible, but then you should keep the source files in a different branch). Just run the plugin like this: npx angular-cli-ghpages --branch=BRANCH-NAME --dir=www.
Like Gary Großgarten suggested, you can create a script for it which makes it easier. For Ionic it would be: ionic build --prod -- --base-href https://YOUR_GITHUB_USERNAME.github.io/YOUR_PROJECT_NAME/ && npx angular-cli-ghpages --branch=BRANCH-NAME --dir=www
I was looking for a proper solution myself, credits go to Juangui Jordán's blog.
I'm using https://github.com/angular-schule/angular-cli-ghpages to achieve this easily.
Just add
"scripts": {
...
"gh-pages": "ng build --base-href 'https://USERNAME.github.io/REPOSITORY_NAME/' --prod && npx ngh --dir=www/"
...
}
to your package.json.
If you want a costum domain you can add the cname flag
--cname=example.com
to the ngh command.
To build and upload your site run
npm run gh-pages
Just a note: For a gitlab repository (not Github) you can do this:
.gitlab-ci.yml:
pages:
image: node:latest
stage: deploy
script:
- npm install -g ionic cordova
- npm install
# frontend application is served at https://what-digital.gitlab.io/stemba/
# we need to set the basePath to the sub dir
- ionic build --prod -- --base-href="https://what-digital.gitlab.io/gitlab-pages/"
- rm -rf public
- mkdir public
- cp -r www/* public
artifacts:
expire_in: 1 week
paths:
- public
only:
- dev
I am trying to get just one folder to build (see above). I have the following YML file in that folder:
version: '0.0.{build}'
image: Visual Studio 2017
configuration: Release
build: off
notifications:
- provider: Email
to:
- keith#sol3.net
subject: CI build 0.0.{build} failed!
on_build_success: false
on_build_failure: true
on_build_status_changed: false
init:
# Best practice (Windows line endings different to Unix/Linux)
- cmd: git config --global core.autocrlf true
install:
appveyor DownloadFile https://dist.nuget.org/win-x86-commandline/v4.0.0/nuget.exe
before_build:
# Display .NET Core version
- cmd: dotnet --version
# Change to specific project folder
- cmd: cd Sol3.Infrastructure
# Display minimal restore text
- cmd: dotnet restore Sol3.Infrastructure.csproj --verbosity m
build_script:
- cmd: dotnet build Sol3.Infrastructure.csproj
- cmd: dotnet pack -c Release /p:PackageVersion=0.0.{build}
after_build:
# For once the build has completed
on_finish :
# any cleanup in here
deploy: off
Constantly getting error of too many SLN/PRJ files. Also noticed that it is NOT using this file as the version is matching the default settings in Appveyor itself.
Appveyor's appveyor.yml file:
version: 1.0.{build}
build:
verbosity: minimal
Can appveyor do this? Is appveyor the best choice? Any guidance?
This is my sandbox (tiny right now) and I have several projects and would like each project to have it's own appveyor.yml file. I do have SLN files in there too and those are artifacts from VS2017 before I switched to VSCode. Thinking I should delete those now until I need to put a SLN together...
By default AppVeyor checks for appveyor.yml or .appveyor.yml in the root of your repo. If you need to specify custom file name or custom path (relative to the repo root), you need to do this in Custom configuration .yml file name filed in General project setting. Some more information is here. What probably happens now is that AppVeyor has not idea about your YML file in the Sol3.Infrastructure and goes with default configuration in which it searches for VS solution or project to build.
Side notes:
nuget is pre-installed
I would recommend using paths relative to the build folder, instead
of doing CD
no need to cleanup at on_finish, each build runs on transient VM,
which is being deleted right after build finished